Last active
November 13, 2020 13:46
-
-
Save timgaunt/9933156 to your computer and use it in GitHub Desktop.
Set Umbraco folder permissions on IIS
This file contains 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
$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