Skip to content

Instantly share code, notes, and snippets.

@timgaunt
Last active November 13, 2020 13:46
Show Gist options
  • Save timgaunt/9933156 to your computer and use it in GitHub Desktop.
Save timgaunt/9933156 to your computer and use it in GitHub Desktop.
Set Umbraco folder permissions on IIS
$PhysicalPath = "[Path to Website]"
$appPoolAccount = "IIS_IUSRS"
$readExecute = $appPoolAccount,"ReadAndExecute","ContainerInherit,ObjectInherit","None","Allow"
$read = $appPoolAccount,"Read","ContainerInherit,ObjectInherit","None","Allow"
$modify = $appPoolAccount,"Modify","ContainerInherit,ObjectInherit","None","Allow"
$fileModify = $appPoolAccount,"Modify","Allow"
$objects = @{}
$objects["App_Browsers"] = $readExecute
$objects["App_Data"] = $modify
$objects["App_Plugins"] = $modify
$objects["bin"] = $modify
$objects["Config"] = $modify
$objects["Css"] = $modify
$objects["Media"] = $modify
$objects["Scripts"] = $modify
$objects["Umbraco"] = $modify
$objects["UserControls"] = $modify
$objects["Views"] = $modify
$objects["Web.config"] = $fileModify
$objects["Umbraco_Client"] = $modify
# Only needed if you're not using Umbraco 7+
# $objects["Xslt"] = $modify
# $objects["App_Code"] = $modify
# $objects["Masterpages"] = $modify
# $objects["MacroScripts"] = $modify
foreach($object in $objects.Keys){
$path = Join-Path $PhysicalPath $object
try {
$acl = Get-ACL $path
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($objects[$object])
$acl.AddAccessRule($rule)
Set-Acl $path $acl
Get-Acl $path | Format-List
}
catch [System.Exception]
{
Write-Host "Unable to set ACL on" $path
Write-Host $_.Exception.GetType().FullName, $_.Exception.Message
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment