Invokes a command on an Active WinSCP Session.
Invoke-WinSCPCommand [-WinSCPSession] <Session> [-Command] <String[]> [<CommonParameters>]
Invokes a command against the remote system hosting the FTP/SFTP Service.
WinSCPSession <WinSCP.Session>
A valid open WinSCP Session, returned from New-WinSCPSession.
Command to execute.
CommonParameters <CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
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:\> $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:\> Invoke-WinSCPCommand -WinSCPSession $session -Command ("mysqldump --opt -u {0} --password={1} --all-databases | gzip > {2}" -f $dbUsername, $dbPassword, $tempFilePath)