Skip to content

Instantly share code, notes, and snippets.

@jszabo98
Last active November 27, 2023 23:00
Show Gist options
  • Save jszabo98/76c44fd04ee7d9ad831ccf18cd2c1097 to your computer and use it in GitHub Desktop.
Save jszabo98/76c44fd04ee7d9ad831ccf18cd2c1097 to your computer and use it in GitHub Desktop.
acls powershell
$acl = Get-Acl -Path C:\SpecialFolder\SpecialFile.txt
$user = 'BillB'
$rights = [System.Security.AccessControl.FileSystemRights]'ReadAndExecute, Write, Modify, Read' # enum flags
$rights
Modify
$RuleBillB = [System.Security.AccessControl.FileSystemAccessRule]::new($user, $rights, 'Allow')
$RuleBillB
FileSystemRights : Modify, Synchronize
AccessControlType : Allow
IdentityReference : BillB
IsInherited : False
InheritanceFlags : None
PropagationFlags : None
$acl.AddAccesssRule($RuleBillB)
Set-Acl -Path C:\SpecialFolder\SpecialFile.txt -AclObject $acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment