File Name when using GetFilesToDirectory
I'm working on a PowerShell script to copy files from an SFTP location to a local machine. Everything is working fine, except for some data I want to obtain once the file(s) are transferred.
When I execute the script I see that it is returning an object showing
I'm not sure if I'm missing something or this feature doesn't exist?
Code for transfer:
When I execute the script I see that it is returning an object showing
IsSuccess
and FileName
. I want to be able to take the returned information and then insert it to a SQL table for later use by another application. I'm able to access the value for IsSuccess
but not for FileName
(see attachment for output).
I'm not sure if I'm missing something or this feature doesn't exist?
Code for transfer:
#Create WinSCP session $WinSCPSession = New-WinSCPSession -SessionOption (New-WinSCPSessionOption -HostName $sftphost -Protocol Sftp -PortNumber $port -Credential $Cred -SshHostKeyFingerprint $sftpfingerprint) #Transfer files to local directory $WinSCPSession.GetFilesToDirectory($sftpDownloadDir,$localDir,'',$deleteRemote) #return $filename $WinSCPSession.close() $WinSCPSession.Dispose()