Created
May 10, 2019 08:04
-
-
Save v-2vinty/097b1a1378c3bef1192c77543809a9a4 to your computer and use it in GitHub Desktop.
script to modify DNS server IP on multiple windows clients at once.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$computer = get-content c:\temp\servers.txt | |
foreach ($comp in $computer) | |
{ | |
try{ | |
$a = (Get-WmiObject -Class Win32_NetworkAdapterConfiguration -ComputerName $comp -ErrorAction Stop | Where-Object {$_.ipenabled -eq "true"}).InterfaceIndex | |
Invoke-Command -ComputerName $comp -ScriptBlock {param( $b) netsh interface ip delete dns name=$b 10.10.220.1 } -args $a -ErrorAction Stop | |
} | |
catch | |
{ | |
Write-Output "Failed $comp" | Out-File c:\temp\error.txt -Append | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment