Send objects to an active WinSCP Session.
Send-WinSCPItem [-WinSCPSession] <Session> [-Path] <String[]> [[-Destination] <String>] [-Remove] [[-TransferOptions] <TransferOptions>] [<CommonParameters>]
After creating a valid WinSCP Session, this function can be used to send files or folders to the remote host, as well as delete the source files after completion.
WinSCPSession <WinSCP.Session>
A valid open WinSCP Session, returned from New-WinSCPSession.
Specifies a path to one or more locations on the local host.
Full path to upload the file to. When uploading multiple files, the filename in the path should be replaced with ConvertTo-WinSCPEscapedString or omitted (path ends with slash).
When present, deletes source file(s) after transfer.
TransferOptions <WinSCP.TransferOptions>
Defines options for file transfers.
CommonParameters <CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
WinSCP.TransferOperationResult
If the WinSCPSession is piped into this command, the connection will be closed and the object will be disposed upon completion of the command.
PS C:\> New-WinSCPSession -Credential (New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $env:USERNAME, (New-Object -TypeName System.Security.SecureString)) -HostName $env:COMPUTERNAME -Protocol Ftp | Send-WinSCPItem -Path 'C:\lDir\lFile.txt' -Destination '/rDir/rFile.txt'
Transfers Failures IsSuccess
--------- -------- ---------
{C:\lDir\lFile.txt} {} True
PS C:\> $credential = Get-Credential
PS C:\> $session = New-WinSCPSession -Credential $credential -Hostname 'myftphost.org' -SshHostKeyFingerprint 'ssh-rsa 1024 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx'
PS C:\> Send-WinSCPItem -WinSCPSession $session -Path 'C:\lDir\lFile.txt' -Destination '/rDir/rFile.txt' -Remove
Transfers Failures IsSuccess
--------- -------- ---------
{C:\lDir\lFile.txt} {} True