Set file permissions while doing powershell file transfer
I have this simple script that transfers a few files, the problem is that the files transfer with 0660 permissions and I need them to be 0644, how can I set this during the transfer process?
Add-Type -Path "D:\FTPScripts\WinSCPnet.dll" $sessionOptions = New-Object WinSCP.SessionOptions -Property @{ Protocol = [WinSCP.Protocol]::Sftp HostName = "example.com" UserName = "user" Password = "mypassword" SshHostKeyFingerprint = "ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx" } $session = New-Object WinSCP.Session $Path = "Uploads/" try { $session.Open($sessionOptions) $session.PutFiles("D:\UserRoles\*UserList*", "$Path/reconUserPath/", $False, $transferOptions) $session.PutFiles("D:\UserRoles\*UserRole*", "$Path/reconURolePath/", $False, $transferOptions) $session.PutFiles("D:\UserRoles\*ROLES*", "$Path/reconRolePath/", $False, $transferOptions) } finally { $session.Dispose() }