Topic "powershell connection to sftp via WinSCP"

Author Message
clt

Guest


Hi, thank you for Winscp!
I'm trying to make script in powershell to download and upload files to sftp server. It works well, but I need to check if the folder where I want to upload files is empty. Next thing I need to make is compare the length of files transfered to sftp with files on my local disc. I'm using

if (@(Compare-Object $files_sftp $files_local -SyncWindow 0).Length -eq 0) {
Write-Host "OK" }
else { Write-Host "NOT ok" }

So I need to get content of remote directory with powershell command Get-Childitem to variable $files_sftp or some general advice how to connect winscp scipting with powershell.
Thank you very much!
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
I do not know powershell (though we would like to add powershell example eventually). But you definitelly need to make use of Session.ListDirectory method:
http://winscp.net/eng/docs/library_session_listdirectory
_________________
Martin Prikryl
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24553
Location: Prague, Czechia
Basic PowerShell example added
http://winscp.net/eng/docs/library#powershell
More examples (and syntax highlighting) coming soon.
_________________
Martin Prikryl
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License