Skip to content

Instantly share code, notes, and snippets.

@sheastrickland
Created November 5, 2015 05:26
Show Gist options
  • Save sheastrickland/412e8708b10d0c875c7c to your computer and use it in GitHub Desktop.
Save sheastrickland/412e8708b10d0c875c7c to your computer and use it in GitHub Desktop.
Powershell DSC for allowing override for system.webserver.security.ipSecurity in applicationHost.config
Script EnableIpSecurityOverride
{
#Allows override for system.webserver.security.ipSecurity in applicationHost.config
DependsOn = "[Script]PreviousStepGoesHere"
SetScript = {
$current = Get-WebConfiguration /system.webServer/security/ipSecurity -Metadata | select -ExpandProperty metadata | select -ExpandProperty effectiveOverrideMode
$expected = "Allow"
$incorrect = $current -ne $expected
if ($incorrect) {
try
{
Start-WebCommitDelay
Set-WebConfiguration /system.webServer/security/ipSecurity -metadata overrideMode -value Allow -Verbose
Stop-WebCommitDelay -Commit $true
}
catch [System.Exception]
{
$_ | Out-String
}
}
}
TestScript = {
$current = Get-WebConfiguration /system.webServer/security/ipSecurity -Metadata | select -ExpandProperty metadata | select -ExpandProperty effectiveOverrideMode
$expected = "Allow"
$result = $current -eq $expected
return $result
}
GetScript = {
$current = Get-WebConfiguration /system.webServer/security/ipSecurity -Metadata | select -ExpandProperty metadata | select -ExpandProperty effectiveOverrideMode
$settings = @{ "ipSecurity" = $currentIpSecurity }
return $settings
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment