Created
July 26, 2017 17:57
-
-
Save ctigeek/5f91ac17468c93f24582de6de455620b to your computer and use it in GitHub Desktop.
Enable dynamic IP throttling in IIS.
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
function Enable-DynamicIpThrottling($webSiteName, [bool] $enabled, [int]$maxRequests, [int]$intervalMilliseconds, [bool] $loggingOnly = $false) { | |
##https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/dynamicipsecurity/ | |
Add-Type -Path "$env:SystemRoot\System32\inetsrv\Microsoft.Web.Administration.dll" | |
$manager = New-Object Microsoft.Web.Administration.ServerManager | |
$config = $manager.GetApplicationHostConfiguration(); | |
$cpSecConfig = $config.GetSection("system.webServer/security/dynamicIpSecurity", $websiteName) | |
$cpSecConfig.SetAttributeValue("enableLoggingOnlyMode", $loggingOnly) | |
$requestRate = $cpSecConfig.ChildElements["denyByRequestRate"] | |
$requestRate.SetAttributeValue("enabled", $enabled) | |
$requestRate.SetAttributeValue("maxRequests", $maxRequests) | |
$requestRate.SetAttributeValue("requestIntervalInMilliseconds", $intervalMilliseconds) | |
$manager.CommitChanges() | |
$manager.Dispose() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment