Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

saporter

Re: Don't quite understand how to write get with - delete in powershell

Oh, I may have figured it out- I may just have to change $False to $True...

$transferResult = $session.GetFiles("/directory/XDOWNLOADS/fileA", "c:\windowsdirectory\fileA", $False, $transferOptions)

if that doesn't work I'll look at $session.removefiles
saporter

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