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

martin

Re: Powershell winscp filepermissions

As shown above, this is the correct code:
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.FilePermissions = New-Object WinSCP.FilePermissions
$transferOptions.FilePermissions.Octal = "0775"


Alternatively, like this:
$transferOptions = New-Object WinSCP.TransferOptions -Property @{
    TransferMode = [WinSCP.TransferMode]::Binary
    FilePermissions = New-Object WinSCP.FilePermissions -Property @{ Octal = "0775" }
}


You can have the latter code generated by WinSCP GUI:
https://winscp.net/eng/docs/ui_generateurl#code
rams

Powershell winscp filepermissions

I have to use the following:
Write-Host "transferOptions.FilePermissions Object Creation ..."
           
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.Octal = New-Object WinSCP.FilePermissions
$transferOptions.Octal = "0775"

Why?
Reason: $transferOptions.FilePermissions is NOT valid property error?
Write-Host "Uploading $line ..."
 
$transferResult = $session.PutFiles($line, $remotePath, $false, $transferOptions).Check()

Please help?
notbroken

Re: Help setting $transferOptions.FilePermissions in powershell

@martin: Worked perfectly. Thank you
martin

Re: Help setting $transferOptions.FilePermissions in powershell

Use:
$transferOptions.FilePermissions = New-Object WinSCP.FilePermissions
$transferOptions.FilePermissions.Octal = "666"
notbroken

Help setting $transferOptions.FilePermissions in PowerShell

I need to set the file permissions to octal 666 in PowerShell.
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.FilePermissions = ?

I am new to PowerShell and am trying to work through this "Create new instance of FilePermissions and set FilePermissions.Octal to a value of the switch."

Any help/guidance would be appreciated