Skip to content

Instantly share code, notes, and snippets.

@v-2vinty
Created May 10, 2019 08:04
Show Gist options
  • Save v-2vinty/097b1a1378c3bef1192c77543809a9a4 to your computer and use it in GitHub Desktop.
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.
$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