Skip to content

Instantly share code, notes, and snippets.

@gravcat
Created June 29, 2017 13:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gravcat/93e3fc1f159647f48d80f98698c79f7c to your computer and use it in GitHub Desktop.
Save gravcat/93e3fc1f159647f48d80f98698c79f7c to your computer and use it in GitHub Desktop.
# must be run in administrator context
param (
[String] $path, # file or folder
[String] $perm, # fullcontrol, read, write, etc
[String] $action = "allow" #allow or deny
[String] $user
)
$arguments = $user, $perm, $action
$acl = Get-Acl $path
$ar = New-Object system.security.accesscontrol.filesystemaccessrule($arguments)
$acl.SetAccessRule($ar)
$acl | Set-Acl $path
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment