Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

netrecov

this is what worked:

[code] 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
$TransferOptions.PreserveTimestamp = $false

# Upload files, collect results
$transferResult = $session.PutFiles($localPath, $remotePath, $false, $transferoptions)[/code]
netrecov

help with -nopreservetime

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. Any help would be greatly appreciated.

[code] # 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)[/code]

this is normally :

$transferResult = $session.PutFiles($localPath, $remotePath)

I am just trying to diable preserve timestamp. I have it off in the gui but it isnt 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#####/##/"