Skip to content

Instantly share code, notes, and snippets.

@a5ync
Created April 19, 2016 23:49
Show Gist options
  • Save a5ync/c0b95490983ee09cb7bbb755ceb85291 to your computer and use it in GitHub Desktop.
Save a5ync/c0b95490983ee09cb7bbb755ceb85291 to your computer and use it in GitHub Desktop.
Set full permission on files from the given folder +filter [optional]
$user = "test"
$remoteFiles = Get-ChildItem "C:\img" -Filter *.png
foreach ($file in $remoteFiles)
{
Write-Host Changing permission of $file.FullName
#change permission
$Acl = Get-Acl $file.FullName
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule($user, "FullControl", "None", "None", "Allow")
$Acl.SetAccessRule($Ar)
Set-Acl $file.FullName $Acl
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment