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 (https://winscp.net/forum/viewtopic.php?p=54781#54781), this is correct code:

$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.TransferMode = [WinSCP.TransferMode]::Binary
$transferOptions.FilePermissions = New-Object WinSCP.FilePermissions
$transferOptions.FilePermissions.Octal = "0775"


Alternativelly, 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 wrote:

Ue:
$transferOptions.FilePermissions = New-Object WinSCP.FilePermissions

$transferOptions.FilePermissions.Octal = "666"



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

Powershell

I need to set the file permissions to Octal 666.

$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