Skip to content

Instantly share code, notes, and snippets.

@ducas
Last active August 29, 2015 14:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducas/e118eb4229ded49a61f1 to your computer and use it in GitHub Desktop.
Save ducas/e118eb4229ded49a61f1 to your computer and use it in GitHub Desktop.
Umbraco helpers for Octopus Deploy
function Set-UmbracoPermissions($SitePath, $AppPoolAccount, $PathOverrides)
{
$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_Code"] = $modify
$objects["App_Data"] = $modify
$objects["bin"] = $modify
$objects["Config"] = $modify
$objects["Css"] = $modify
$objects["MacroScripts"] = $modify
$objects["Masterpages"] = $modify
$objects["Media"] = $modify
$objects["Scripts"] = $modify
$objects["Umbraco"] = $modify
$objects["Umbraco_Client"] = $modify
$objects["UserControls"] = $modify
$objects["Views"] = $modify
$objects["Web.config"] = $fileModify
$objects["Xslt"] = $modify
foreach($directory in $objects.Keys) {
$path = Join-Path $SitePath $directory
if ($PathOverrides.Keys -contains $directory) {
$path = $PathOverrides[$directory]
}
Write-Host "Setting permissions on $directory directory - '$path'."
if (-not (Test-Path $path)) {
Write-Warning "'$path' does not exist. Moving on..."
continue;
}
$acl = Get-ACL $path
$rule = New-Object System.Security.AccessControl.FileSystemAccessRule($objects[$directory])
$acl.AddAccessRule($rule)
Set-Acl $path $acl
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment