Use PsExec and Netsh to Change DNS Server on Remote Computer

The other day, one of my scripts changed the DNS server on a desktop to an incorrect server. It killed that computer’s Internet access so I lost control through my RMM tool. However I was able to ping the computer from another computer on the network.

I know how to change DNS with PowerShell, but PowerShell remoting to the problem computer (using Enter-PSSession) didn’t work. Maybe a firewall issue.

Sysinternals to the rescue! PsExec got me a command prompt on the remote machine, and from there I was able to use netsh to update the computer’s DNS and get it back online:

netsh interface ip set dns "Local Area Connection" static 8.8.8.8

A big thanks to ingram’s 2011 (!) post here, which explains both PsExec and the necessary netsh commands:

http://itswapshop.com/content/how-set-or-change-ip-addresses-gateways-subnet-masks-and-dns-servers-remotely-windows

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.