Skip to content

Instantly share code, notes, and snippets.

@sheastrickland
Created November 5, 2015 05:26

Revisions

  1. sheastrickland created this gist Nov 5, 2015.
    33 changes: 33 additions & 0 deletions EnableIpSecurityOverride.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,33 @@
    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
    }
    }