Skip to content

Instantly share code, notes, and snippets.

@joeywas
Created February 4, 2021 17:16
Show Gist options
  • Save joeywas/131932b032ff21b1bd250dcd702bec0c to your computer and use it in GitHub Desktop.
Save joeywas/131932b032ff21b1bd250dcd702bec0c to your computer and use it in GitHub Desktop.
recursive acl change
$acl = Get-Acl -Path "H:\"
$acl.SetAccessRuleProtection($true,$false)
$acl.Access | ForEach-Object { $acl.RemoveAccessRule($_) | Out-Null }
$ace = New-Object System.Security.Accesscontrol.FileSystemAccessRule ("Everyone", "FullControl", "ContainerInherit,ObjectInherit", "InheritOnly", "Allow")
$acl.AddAccessRule($ace)
Set-Acl -Path "H:\" -AclObject $acl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment