Don't quite understand how to write get with - delete in powershell
Hello!
I've looked at some examples for how to delete a file after it is downloaded, using get -delete, but I don't quite understand how to write this in powershell. Using winscp 5.7.6, and powershell 3, I'm trying to sftp to a Linux server and download a file, and delete the file after it has downloaded. I can download the file but I don't know how to delete it from the server afterward. Here is my code:
# connect
$session.Open($sessionOptions)
# download files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult = $session.GetFiles("/directory/XDOWNLOADS/fileA", "c:\windowsdirectory\fileA", $False, $transferOptions)
# Disconnect
$session.Dispose()
I've looked at some examples for how to delete a file after it is downloaded, using get -delete, but I don't quite understand how to write this in powershell. Using winscp 5.7.6, and powershell 3, I'm trying to sftp to a Linux server and download a file, and delete the file after it has downloaded. I can download the file but I don't know how to delete it from the server afterward. Here is my code:
# connect
$session.Open($sessionOptions)
# download files
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferResult = $session.GetFiles("/directory/XDOWNLOADS/fileA", "c:\windowsdirectory\fileA", $False, $transferOptions)
# Disconnect
$session.Dispose()