I am trying to add -nopreservetime
to this code. I am not sure where or how to add it, I have tried different things to no result.
# Setup session options
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::Sftp
$sessionOptions.HostName = "#######.com"
$sessionOptions.UserName = "#####"
$sessionOptions.Password = "#####"
$sessionOptions.SshHostKeyFingerprint = "#####"
$sessionOptions.Timeout = "##"
$TransferOptions.PreserveTimestamp = $false
$session = New-Object WinSCP.Session
$Session.SessionLogPath = "C:\Users\user1\Desktop\Winscp\TEST\sessionlog.txt"
$Session.debugLogPath = "C:\Users\user1\Desktop\Winscp\TEST\debugsessionlog"+$date+".txt"
try
{
Write-Host $date,("Connecting to FTP site.")
# Connect
$session.Open($sessionOptions)
Write-Host $date,("Connected to FTP site.")
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
# Upload files, collect results
$transferResult = $session.PutFiles("$localPath", "$remotePath", $False, $transferOptions)
}
This is normally:
$transferResult = $session.PutFiles($localPath, $remotePath)
I am just trying to disable preserve timestamp. I have it off in the GUI but it isn't working in the powershell_ise.exe
The above code returns this in the log:
2015-07-20 08:52:44.635 Script: put -nopermissions -preservetime -transfer="binary" -- "C:\Users\user\Desktop\Winscp############*.pdf" "/OUTGOING/TEST#####/##/"