Skip to content

Instantly share code, notes, and snippets.

@mguinness
mguinness / IIS_IP_Blocker.ps1
Created December 24, 2020 23:06
Auto block IPv4 addresses in IIS from suspect log entries
<#
Uses Microsoft Log Parser (https://en.wikipedia.org/wiki/Logparser) to parse IIS logs for given criteria and both auto
blocks the IP in IIS (under IP Address and Domain Restrictions) and also reports to AbuseIPDB (IP Address Blacklist).
Modify site, dir & query variables to suit your specific site requirements. Run script in Task Scheduler every 15 mins.
Log Parser Component Object Model (COM) must be registered in Windows and script should be run with suitable permissions.
#>
$utc = (Get-Date).ToUniversalTime()