My environment is a static IP one and I must change the DNS settings on all the WinXP and Win7 clients. I pretty much have the gist of the script down except maybe part of the loops. The first loop just checks to see if the PC is accessible, then runs thru a text file with all the hosts and should output the hostname and the NIC description for each. The problem is that the $nic.description is always the same for each machine even though there are several different NICs in use here. Most of them are Intel(R) 82579LM but I know that most of the laptops should come back saying Inter(R) Centrino(R) - but EVERYTHING is saying 82579 so i'm not convinced this is working right. My text file only has 3 PCs and 1 laptop in it while I test this, before I commit the command to all 2000 machines get false positives.
$servers = get-content c:\pc.txt $nics = get-wmiobject win32_networkadapterconfiguration | where-object {$_.DHCPEnabled -eq $False -and $_.IPAddress -gt 1} $newDNS = "10.100.67.137","10.100.67.224" foreach($server in $servers) { if (Test-Connection -ComputerName $server -Count 1 -quiet) { Write-Host "" Write-Host "Connecting to $server..." foreach($nic in $nics) { Write-Host "`tExisting DNS Servers on" $server $nic.description "was" $nic.DNSServerSearchOrder $x = $nic.SetDNSServerSearchOrder($newDNS) if($x.ReturnValue -eq 0) { Write-Host "`tSuccess! Changed DNS on" $server $nic.description "now" $newDNS } else { Write-Host "`tFailed to change DNS on" $server } } } else { write-host "" write-host "Failed to connect to " $server } }