Where to add -passive=on|off into a PowerShell WinSCP script
Hello,
I need help! I am trying to understand where to add
Can someone help out where I can add the parameter in my code so I can turn off or on passive mode?
Thanks in advance!
Regards,
Nikola
I need help! I am trying to understand where to add
-passive=on|off
parameter into a WinSCP PowerShell script. This is my code:
#Set up session options $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = $FTPpath UserName = $user Password = $pass SshHostKeyFingerprint = $fingerprint } $sessionOptions.AddRawSettings("KEX", "dh-group1-sha1,ecdh,dh-gex-sha1,dh-group14-sha1,rsa,WARN") $sessionOptions.AddRawSettings("FSProtocol", "2") $session = New-Object WinSCP.Session #Connect $session.Open($sessionOptions) #Download files $transferOptions = New-Object WinSCP.TransferOptions $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary $remotePath = Split-Path -Path $FilesToRetrieve -Parent Write-Host "Remote Path is $remotePath" # Get list of files in the directory $directoryInfo = $session.ListDirectory($remotePath) # Select the most recent file $latest = $directoryInfo.Files | Where-Object LastWriteTime -gt (Get-Date).AddDays(-$LastWriteTimeDays) Write-Host "LastWriteTime is $latest"
Thanks in advance!
Regards,
Nikola