From 8c0175ad5e7df687714fe26365df6de0db37f9f3 Mon Sep 17 00:00:00 2001 From: Nicole Rappe Date: Fri, 29 May 2026 17:33:30 -0600 Subject: [PATCH] Add scripts/Powershell/General Purpose/Remotely Change DNS Records.md --- .../Remotely Change DNS Records.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 scripts/Powershell/General Purpose/Remotely Change DNS Records.md diff --git a/scripts/Powershell/General Purpose/Remotely Change DNS Records.md b/scripts/Powershell/General Purpose/Remotely Change DNS Records.md new file mode 100644 index 0000000..f195819 --- /dev/null +++ b/scripts/Powershell/General Purpose/Remotely Change DNS Records.md @@ -0,0 +1,19 @@ +## Purpose +You may find that for one reason or another, you need to change DNS records of remote windows devices and cannot login via RDP or via console, yet somehow WinRM continues to work. In these scenarios, you can use the following commands to identify the network adapter, change its DNS servers, and verify the settings afterwards. + +!!! info "Run as Domain Admin" + You need to run the following commands within the context of a powershell session running as a domain admin, otherwise the `Invoke-Command` commands will fail to execute. + +```powershell +# Hostname of the Device +$DEVICE = "DEVICEHOSTNAME" + +# Iterate List of Network Interfaces Remotely +Invoke-Command -ComputerName $DEVICE -ScriptBlock { ipconfig /all } + +# List Current DNS Servers for the selected interface +Invoke-Command -ComputerName $DEVICE -ScriptBlock { Get-DnsClientServerAddress -InterfaceAlias "Ethernet" } | Select-Object Address + +# Replace Current DNS Servers for the selected interface +Invoke-Command -ComputerName $DEVICE -ScriptBlock { Set-DnsClientServerAddress -InterfaceAlias "Ethernet" -ServerAddresses ("192.168.3.25","192.168.3.26") } +``` \ No newline at end of file