-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBlock_Nvidia.ps1
More file actions
36 lines (30 loc) · 1.03 KB
/
Block_Nvidia.ps1
File metadata and controls
36 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# Declare host rules
$nvidiaHosts = @(
"0.0.0.0 ls.dtrace.nvidia.com",
"0.0.0.0 telemetry.gfe.nvidia.com",
"0.0.0.0 accounts.nvgs.nvidia.com",
"0.0.0.0 accounts.nvgs.nvidia.cn",
"0.0.0.0 nvidia.tt.omtrdc.net",
"0.0.0.0 api.commune.ly",
"0.0.0.0 login.nvgs.nvidia.com",
"0.0.0.0 login.nvgs.nvidia.cn"
)
# Set file paths
$file = "C:\Windows\System32\drivers\etc\hosts"
$tempfile = "C:\Windows\System32\drivers\etc\temp_hosts"
# Rename the hosts file to allow writing to it
Rename-Item -Path $file -NewName $tempfile
# Get an array of lines from the hosts file
$hostfile = Get-Content $tempfile
# Loop through our host rules
foreach ($entry in $nvidiaHosts) {
# Check if our host file contains the rules
if ($hostfile -notcontains "$entry") {
# Add the rule to the array if it doesn't
$hostfile += "$entry"
}
}
# Write our array to the hosts file
Set-Content -Path $tempfile -Value $hostfile -Force
# Rename the temporary file back to hosts
Move-Item -Path $tempfile -Destination $file -Force