Perfect! Thanks!
- Guest
Before posting, please read how to report bug or request support effectively.
Bug reports without an attached log file are usually useless.
$WinSCPSession = New-WinSCPSession -SessionOption (New-WinSCPSessionOption -HostName $sftphost -Protocol Sftp -PortNumber $port -Credential $Cred -SshHostKeyFingerprint $sftpfingerprint)
$transferResult = $WinSCPSession.GetFilesToDirectory($sftpDownloadDir, $localDir, '', $deleteRemote)
foreach ($fileTransfer in $transferResult.Transfers)
{
$isSuccess = $fileTransfer.IsSuccess
$fileName = $fileTransfer.FileName
# put here inserts to DB like Invoke-Sqlcmd -ServerInstance $sqlServer -Database $database -Query "INSERT INTO YourTable (IsSuccess, FileName) VALUES ('$isSuccess', '$fileName')"
}
$WinSCPSession.Close()
$WinSCPSession.Dispose()
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).
#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()