Notice: Due to size constraints and loading performance considerations, scripts referenced in blog posts are not attached directly. To request access, please complete the following form: Script Request Form Note: A Google account is required to access the form.
Disclaimer: I do not accept responsibility for any issues arising from scripts being run without adequate understanding. It is the user's responsibility to review and assess any code before execution. More information

Update DNS server client IP's remotely using WMI


Sometimes you need to update older server says Server 2003 or older and you cannot use Powershell as its not installed, but you can use WMI. here is now....





$servers = get-content ./servers.txt





foreach($server in $servers)





{





       Write-Output "Connect to $server..."





       $nics = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $servers | where { $_.IPEnabled -eq "TRUE"}





       $newDNS = "8.8.8.8","8.8.4.4"





       foreach($nic in $nics)





       {





       Write-output "`tExisting DNS Servers " $nic.DNSServerSearchOrder





       $x = $nic.SetDNSServerSearchOrder($newDNS)





       if($x.ReturnValue -eq 0)





        {





        Write-Output "`tSuccessfully Changed DNS Servers on " $server





              }





       else





              {





              Write-Output "`tFailed to Change DNS Servers on " $server





              }





       }





}


Previous Post Next Post

نموذج الاتصال