Created
November 5, 2015 05:26
-
-
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
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
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