Change the DNS from a list of servers:
#Change DNS for a list of servers #Get the admin permissions $LoginPassword = Get-Credential #Get the list of computers from a text file $computer = get-content C:\temp\servers.txt #Get the DNS IP's using the get-wmiobject (using wmi as some servers dont have powershell installed) $NICs = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $computer -Credential $LoginPassword |where{$_.IPEnabled -eq “TRUE”} # for each server list the current setting Foreach($NIC in $NICs) { Write-Host "DNS Servers before change:" $NIC.DNSServerSearchOrder #Change the settings to this $DNSServers = "10.10.7.1","10.10.7.2" $NIC.SetDNSServerSearchOrder($DNSServers) #$NIC.SetDynamicDNSRegistration(“TRUE”) #After Change - Not tested Write-Host "DNS Servers after Change:" $NIC.DNSHostName $NIC.DNSServerSearchOrder }
Leave a Reply