-
Notifications
You must be signed in to change notification settings - Fork 30
Send WinSCPItem
Thomas Malkewitz edited this page Jul 9, 2015
·
17 revisions
.SYNOPSIS
Send file(s) to an active WinSCP Session.
.DESCRIPTION
After creating a valid WinSCP Session, this function can be used to send file(s).
.INPUTS
WinSCP.Session.
System.String.
.OUTPUTS
WinSCP.TransferOperationResult.
.PARAMETER WinSCPSession
A valid open WinSCP.Session, returned from Open-WinSCPSession.
.PARAMETER Path
Full path to local file or directory to upload. Filename in the path can be replaced with Windows wildcard to select multiple files. When file name is omitted (path ends with backslash), all files and subdirectories in the local directory are uploaded.
.PARAMETER Destination
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).
.PARAMETER Remove
When present, deletes source local file(s) after transfer.
.PARAMETER TransferOptions
Transfer options. Defaults to null, what is equivalent to New-TransferOptions.
.EXAMPLE
PS C:\> New-WinSCPSession -Credential (New-Object -TypeName System.Managemnet.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
.EXAMPLE
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
.NOTES
If the WinSCPSession is piped into this command, the connection will be closed and the object will be disposed upon completion of the command.
.LINK
http://dotps1.github.io/WinSCP
.LINK
http://winscp.net/eng/docs/library_session_putfiles