Created
December 14, 2014 02:13
-
-
Save DamianMac/8211c53211136e88e9fe to your computer and use it in GitHub Desktop.
Set directory permissions with powershell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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