Skip to content

Move WinSCPItem

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

Move-WinSCPItem

Synopsis

Moves an item from one location to another from an active WinSCP Session.

Syntax

Move-WinSCPItem [-WinSCPSession] <Session> [-Path] <String[]> [[-Destination] <String>] [-Force] [-PassThru] [<CommonParameters>]

Description

Once connected to an active WinSCP Session, one or many files can be moved to another location within the same WinSCP Session.

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 remote item to be moved.

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

-Destination <String>

Full path to new location to move the item to.

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

-Force <SwitchParameter>

Creates the destination directory if it does not exist.

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

-PassThru <SwitchParameter>

Returns a WinSCP.RemoteFileInfo of the moved object.

Required? false
Position? named
Default value false
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

System.Void

Specifies a return value type for a method that does not return a value.

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 | Move-WinSCPItem -Path '/rDir/rFile.txt' -Destination '/rDir/rSubDir/'

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:\> Move-WinSCPItem -WinSCPSession $session -Path '/rDir/rFile.txt' -Destination '/rDir/rSubDir/' -PassThru

Directory: /rdir/rSubdir

FileType LastWriteTime Length Name


D 1/1/2015 12:00:00 AM 0 rFile.txt

Related links

MoveFile Method
Project Home Page