SFTP powershell script with WinSCP
I'm trying to figure out how to take a file from a PC and upload it unto a SFTP server using WinSCP. I'm getting stuck after I run the command. First a credential window opens and I enter my credentials. That is successful! but then...I get a message that says...
cmdlet Move-WinSCPItem at command pipeline position 1
Supply values for the following parameters:
WinSCPSession:
I don't know what to put in for this "WinSCPSession" value. It just says...
Move-WinSCPItem : Cannot process argument transformation on parameter 'WinSCPSession'. Cannot convert the "" value of type "System.String" to type "WinSCP.Session".
At line:3 char:1
+ Move-WinSCPItem -Path "/PlutoP/NewFolder/Document.csv" -Destination "C:\U ...
I've tried Send-WindSCPItem, move-WinSCPSessionOption, Receive-WinSCPItem, New-WinSCPSession, New-WinSCPSessionOption.. Needless to say, I am new to this and would be grateful for any assistance!
Here's the script:
# Piping the WinSCPSession into the Receive-WinSCPItem auto disposes the WinSCP.Session object after completion.
New-WinSCPSessionOption -Hostname "SFTP server address" -Credential (Get-Credential) -SshHostKeyFingerprint "ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx"
Move-WinSCPItem -Path "/PlutoP/NewFolder/Document.csv" -Destination "C:\Users\PlutoP\Download\Document.csv"