Posts

Showing posts from February, 2017
Some PowerShell code to change DNS servers on a set of windows boxes.... Might be useful - have I posted this before???  Maybe not with any Try/Catch stuff... Make a list of machines names in a txt file "c:\scripts\machinelist.txt" - is my example... Copy the following into a ps1 file (enable scripts to run!) and run as an admin on all the machines in the list (domain admin?)...done. # # Script to set the DNS Settings on a Windows box # $computerList = get-content c:\scripts\machinelist.txt $date = Get-Date -format D $log = "---------------- Log Starting : $date ----------------`r`n" ForEach($computer in $computerList){ # Do some logging?? try{ $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer -ErrorAction stop         $NICs = $NICs | where{$_.IPEnabled -eq “TRUE” -and $_.Description -match "Wireless"} ForEach($NIC in $NICs){ $DNSServers = ”1.2.3.4","1,2,3,5",“1.2.3.6"