From 6151c51531c56269323b5559381dab6a91fbaacc Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Wed, 4 Apr 2018 15:16:22 +0200 Subject: [PATCH] BlockHostByIP() use GetAddressIP instead ResolvDNSName to retrieve IP with hostname --- cleanW10.ps1 | 11 ++++++----- modules.d/FW_BlockIP/telemetry.txt | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/cleanW10.ps1 b/cleanW10.ps1 index 9717fe9..8397c05 100755 --- a/cleanW10.ps1 +++ b/cleanW10.ps1 @@ -63,14 +63,15 @@ function BlockHostByIP { param( [string]$hostname ) - $resolv = Resolve-DnsName $hostname -ErrorAction SilentlyContinue | select Address,Type | Where { $_.type -match "^A{1,4}$" } + $resolv = [system.net.Dns]::GetHostAddresses($hostname) | Select IPAddressToString + #$resolv = Resolve-DnsName $hostname -ErrorAction SilentlyContinue | select Address,Type | Where { $_.type -match "^A{1,4}$" } $resolv | Foreach { - Write-Host -NoNewLine "`t`t" - if ($_.Address -match $IP4_REGEX ) { Write-Debug "Found a valid IPv4 $($_.Address)" } - $ip = $_.Address + Write-Host -NoNewLine "`t" + $ip = $_.IPAddressToString + Write-Debug "Found a valid IP $($_.IPAddressToString)" $rule = Get-NetFirewallAddressFilter | Where-Object { $_.RemoteAddress -eq $ip } | Get-NetFirewallRule if ( $rule ) { - write-host -NoNewLine "FW Rule exist : " + write-host -NoNewLine "`tFW Rule exist : " write-host -ForegroundColor yellow $rule.name } else { diff --git a/modules.d/FW_BlockIP/telemetry.txt b/modules.d/FW_BlockIP/telemetry.txt index b35786f..b4c2ce2 100644 --- a/modules.d/FW_BlockIP/telemetry.txt +++ b/modules.d/FW_BlockIP/telemetry.txt @@ -349,7 +349,7 @@ 195.138.255.0-195.138.255.255 213.199.179.0-213.199.179.255 191.232.139.2-191.232.139.255 -=23.55.155.27 +23.55.155.27 23.214.171.90 64.4.11.25 65.52.100.46 @@ -363,4 +363,4 @@ 221.221.112.129 221.221.112.145 221.221.112.160 -221.221.112.203 +221.221.112.203 \ No newline at end of file