Topic "transferOptions.FilePermissions question."

Author Message
AJDValien
[View user's profile]

Joined: 2012-08-08
Posts: 3
Hi all,

Not sure if this is the right forum or not. Been automating WinSCP using some Powershell scripts. But when I do an upload I get this error:

Code:
PS R:\PowerShellScripts> .\SFTPToPDCs.ps1
Beginning FTP Upload.
Upload of file '1208E.pjb' was successful, but error occurred while setting the
permissions and/or timestamp. If the problem persists, turn on 'Ignore permissio
n errors' option.
PS R:\PowerShellScripts> .\SFTPToPDCs.ps1


So looking around the documentation I stumbled on this:

http://winscp.net/eng/docs/library_filepermissions
and this to remove it via the GUI or command line - http://winscp.net/eng/docs/ui_transfer_custom#upload_options

So how would I implement this in my script? I looked at the PS examples but no go.

Would this work? (text in red)

$transferOptions.FilePermissions = $Null

The idea is to keep the permissions the same when I upload the files.

Code:
# Connect
      Write-Host "Beginning FTP Upload."
        $session.Open($sessionOptions)
 
        # Upload files
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
   $transferOptions.FilePermissions = $Null
      
      $transferResult = $session.PutFiles("R:\RESOURCES\Data\*", "/users/xfer/", $FALSE, $transferOptions)
Advertisements
Southbay
[View user's profile]

Joined: 2012-08-09
Posts: 1
Location: USA
I'm having the exact same problem. I'm using WS_FTP as the destination server and I can get a single file uploaded but then it throws the exception. I attempted your TransferOptions.FilePermissions=$Null idea but no go for me. I really wish I could have gotten this to work, put a bit of time into this powershell script which wraps winscp.
AJDValien
[View user's profile]

Joined: 2012-08-08
Posts: 3
Wow, surprised no one else has weighed in on this. For now I have to manually FTP (using FileZilla) instead of WinSCP since I can't override (or figure out the override) on the permissions to automate it. Sad
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24512
Location: Prague, Czechia
Please read documentation:
http://winscp.net/eng/docs/faq_not_owner

If that does not help, come back.
_________________
Martin Prikryl
AJDValien
[View user's profile]

Joined: 2012-08-08
Posts: 3
Just now getting back to this. Was able to test this tonight and PowerShell does not recognize the null option and throws this exception:

The term 'null' is not recognized as the name of a cmdlet, function, script file
, or operable program. Check the spelling of the name, or if a path was included
, verify that the path is correct and try again.

So back to the drawing board...

This is what I had in my PS script:

Code:
        $transferOptions = New-Object WinSCP.TransferOptions
        $transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
      $transferOptions.FilePermissions = null
      $transferOptions.PreserveTimestamp = false


Edit: Got it!

Had to use this for PowerShell to pick it up:

$transferOptions.FilePermissions = $null
$transferOptions.PreserveTimestamp = $false

Worked like a charm!
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