Skip to content

Send WinSCPItem

Thomas Malkewitz edited this page Oct 2, 2015 · 17 revisions

Send-WinSCPItem

Synopsis

Send file(s) to an active WinSCP Session.

Syntax

Send-WinSCPItem [-WinSCPSession] <Session> [-Path] <String[]> [[-Destination] <String>] [-Remove] [[-TransferOptions] <TransferOptions>] [<CommonParameters>]

Description

After creating a valid WinSCP Session, this function can be used to send file(s).

Parameters

-WinSCPSession <Session>

A valid open WinSCP.Session, returned from New-WinSCPSession.

Required? true
Position? 0
Default value  
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-Path <String[]>

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.

Required? true
Position? 1
Default value  
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Destination <String>

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).

Required? false
Position? 2
Default value /
Accept pipeline input? false
Accept wildcard characters? false

-Remove <SwitchParameter>

When present, deletes source file(s) after transfer.

Required? false
Position? named
Default value  
Accept pipeline input? false
Accept wildcard characters? false

-TransferOptions <TransferOptions>

Transfer options. Defaults to null, what is equivalent to New-TransferOptions.

Required? false
Position? 3
Default value (New-Object -TypeName WinSCP.TransferOptions)
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).

Inputs

WinSCP.Session

It represents a session and provides methods for manipulating remote files over SFTP, SCP or FTP session.

System.String

Represents text as a series of Unicode characters.

Outputs

WinSCP.TransferOperationResult

Represents results of transfer operation.

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.

Examples

EXAMPLE 1

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 2

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

Related links

PutFiles Method
Project Home Page