Topic "help with -nopreservetime"

Author Message
netrecov
[View user's profile]

Joined: 2015-07-20
Posts: 3
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#####/##/"
netrecov
[View user's profile]

Joined: 2015-07-20
Posts: 3
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]
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License