|
@ -7,18 +7,24 @@ Import-Module -DisableNameChecking $PSScriptRoot\..\lib\reg-helper.psm1 |
|
|
|
|
|
|
|
|
echo "Adding telemetry domains to hosts file" |
|
|
echo "Adding telemetry domains to hosts file" |
|
|
$hosts = cat "$PSScriptRoot\..\res\telemetry-hosts.txt" |
|
|
$hosts = cat "$PSScriptRoot\..\res\telemetry-hosts.txt" |
|
|
|
|
|
$hosts_file = "$env:systemroot\System32\drivers\etc\hosts" |
|
|
|
|
|
|
|
|
[ipaddress[]] $ips = @() |
|
|
[ipaddress[]] $ips = @() |
|
|
foreach ($h in $hosts) { |
|
|
foreach ($h in $hosts) { |
|
|
try { |
|
|
try { |
|
|
# store for next part |
|
|
# store for next part |
|
|
$ips += [ipaddress]$h |
|
|
$ips += [ipaddress]$h |
|
|
} catch [System.InvalidCastException] { |
|
|
} catch [System.InvalidCastException] { |
|
|
# can be redirected by hosts |
|
|
$contaisHost = Select-String -Path $hosts_file -Pattern $h |
|
|
echo "0.0.0.0 $h" | Out-File -Encoding ASCII -Append "$env:systemroot\System32\drivers\etc\hosts" |
|
|
If(-Not $contaisHost) { |
|
|
|
|
|
# can be redirected by hosts |
|
|
|
|
|
echo "0.0.0.0 $h" | Out-File -Encoding ASCII -Append $hosts_file |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
echo "Adding telemetry ips to firewall" |
|
|
echo "Adding telemetry ips to firewall" |
|
|
|
|
|
Remove-NetFirewallRule -ErrorAction SilentlyContinue -DisplayName "Block Telemetry IPs" |
|
|
New-NetFirewallRule -DisplayName "Block Telemetry IPs" -Direction Outbound ` |
|
|
New-NetFirewallRule -DisplayName "Block Telemetry IPs" -Direction Outbound ` |
|
|
-Action Block -RemoteAddress ([string[]]$ips) |
|
|
-Action Block -RemoteAddress ([string[]]$ips) |
|
|
|
|
|
|
|
|