Skip to content

Instantly share code, notes, and snippets.

@jmoberly
Created December 12, 2013 16:53
Show Gist options
  • Save jmoberly/7931223 to your computer and use it in GitHub Desktop.
Save jmoberly/7931223 to your computer and use it in GitHub Desktop.
Set permission on a folder with powershell
$objType =[System.Security.AccessControl.AccessControlType]::Allow
$colRights = [System.Security.AccessControl.FileSystemRights]"Modify"
$InheritanceFlag = "ContainerInherit, ObjectInherit"
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None
$objUser = New-Object System.Security.Principal.NTAccount("IIS_IUSRS")
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType)
$objACL = Get-ACL "c:\test\Folder"
$objACL.AddAccessRule($rule)
Set-ACL "C:\test\Folder" $objACL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment