Skip to content

Instantly share code, notes, and snippets.

@DamianMac
Created December 14, 2014 02:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DamianMac/8211c53211136e88e9fe to your computer and use it in GitHub Desktop.
Save DamianMac/8211c53211136e88e9fe to your computer and use it in GitHub Desktop.
Set directory permissions with powershell
#create share and set permissions
New-Item -ItemType Directory $sharePathname
$inherit = [system.security.accesscontrol.InheritanceFlags]"ContainerInherit, ObjectInherit"
$propagation = [system.security.accesscontrol.PropagationFlags]"None"
$permission = 'IIS_IUSRS',"FullControl", $inherit, $propagation, "Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$permission = 'NETWORK SERVICE',"FullControl", $inherit, $propagation, "Allow"
$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule $permission
$acl.SetAccessRule($accessRule)
$acl | Set-Acl $sharePathname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment