BlockHostByIP() use GetAddressIP instead ResolvDNSName to retrieve IP with hostname
This commit is contained in:
parent
9cd6d3a7f5
commit
6151c51531
2 changed files with 8 additions and 7 deletions
11
cleanW10.ps1
11
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 {
|
||||
|
|
|
@ -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
|
||||
|
|
Reference in a new issue