PowerShell – and how to add new DNS servers to remote systems

Well, I’ve been playing around with PowerShell today. I had the task to move (as in change the IP address) two domain controllers into another VLAN. I could have done it the easy way and added the DNS servers by hand (by RDP’ing to each system having these particular DNS servers configured) – which wouldn’t have been very hard considering the domain only has 7 members at this point …

I wanted to do it the proper way, so I ended up asking old uncle Google, and it supplied me with the answers I was looking for.

Now, I executed those few PowerShell lines before changing the IP address of both domain controllers (10.76.15.20 being the old IP and 10.76.20.20 being the new one). After that I changed the IP address on the second (and after a short downtime) on the first domain controller. After both were restored and available again (and I checked with repadmin /showrepl), I ran the script again, this time only setting the new DCs:

Well, considering the time I spent on looking for this and the time I would have needed to change even the seven members – even this is a time saver.