Skip to content

Instantly share code, notes, and snippets.

@ducas ducas/Octopus-Umbraco.psm1
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.