isIPsafe

PowerShell

Check and report from Windows scripts with Invoke-RestMethod.

Invoke-RestMethod parses JSON for you, so checking and reporting from Windows scripts is a line or two. Works in Windows PowerShell 5.1 and PowerShell 7.

Check an address

$headers = @{ Authorization = "Bearer $env:ISIPSAFE_KEY" }
$r = Invoke-RestMethod -Uri "https://isipsafe.com/api/v1/check?ip=203.0.113.7&maxAgeInDays=90" -Headers $headers
$r.data | Select-Object ipAddress, abuseConfidenceScore, totalReports, countryCode, isp, categories

Report an address

Invoke-RestMethod -Method Post -Uri "https://isipsafe.com/api/v1/report" -Headers $headers -Body @{
  ip         = "203.0.113.50"
  categories = "rdp,brute-force"
  comment    = "120 failed RDP logons (event 4625) in 10 minutes"
}

A 429 response means you already reported that address in the last 15 minutes; wrap the call in try { } catch { } in loops.

Check many addresses

Get-Content .\addresses.txt | ForEach-Object {
  $d = (Invoke-RestMethod -Uri "https://isipsafe.com/api/v1/check?ip=$_" -Headers $headers).data
  [pscustomobject]@{ IP = $d.ipAddress; Score = $d.abuseConfidenceScore; Reports = $d.totalReports; Country = $d.countryCode }
} | Export-Csv .\results.csv -NoTypeInformation

Ready-made scripts: report RDP brute force, block the list in Windows Firewall, report IIS scanners.

Need a hand?

If something here does not work with your version of PowerShell, or you have improved it, tell us. We update these pages with what people send.

PowerShell and its logo are trademarks of their respective owners. isipsafe is not affiliated with or endorsed by them.