Skip to content

Instantly share code, notes, and snippets.

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 ssougnez/00013c0adb3ba8ae29b3dc1588fef704 to your computer and use it in GitHub Desktop.
Save ssougnez/00013c0adb3ba8ae29b3dc1588fef704 to your computer and use it in GitHub Desktop.
Function SetPermissions {
Param([string]$directory, [string]$appPoolName)
$acl = Get-Acl $destination
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($("IIS APPPOOL\{0}" -f $appPoolName), "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl.SetAccessRule($rule)
Set-Acl $destination $acl
$acl = Get-Acl $destination
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IUSR", "Read", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl.SetAccessRule($rule)
Set-Acl $destination $acl
$acl = Get-Acl $destination
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule("IIS_IUSRS", "Read", "ContainerInherit,ObjectInherit", "None", "Allow")
$acl.SetAccessRule($rule)
Set-Acl $destination $acl
Success
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment