Deleting files after transfer
Hi all,
I'm using the following script to get files from SFTP. Everything is working great but now they came with a demand to delete the files on the source end after getting them.
Can someone help please.
Thanks in advance.
I'm using the following script to get files from SFTP. Everything is working great but now they came with a demand to delete the files on the source end after getting them.
Can someone help please.
Thanks in advance.
# Load WinSCP .NET assembly Add-Type -Path "WinSCPnet.dll" # Set up session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = "***.***.**" PortNumber = 8330 UserName = "****" Password = "****" SshHostKeyFingerprint = "ssh-rsa 4096 rEjkMymlF6K/u182f70hLa7a0r7pwDze5oBRa0dk62U=" } $sessionOptions.AddRawSettings("FSProtocol", "2") $session = New-Object WinSCP.Session try { # Connect $session.Open($sessionOptions) # Transfer files $session.GetFiles("/*", "C:\Users\dady\Documents\*").Check() } finally { $session.Dispose() }