Link to home
Create AccountLog in
Avatar of Anagkazo
AnagkazoFlag for United States of America

asked on

PowerShell Script to check DNS Settings

How do I get the DNS server IPs configured on remote computers that are joined to my Domain using PowerShell.  I am using Window 2012 R2 Domain Controller (Powershell v4).

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Anagkazo
Anagkazo
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Get-NetAdapter -Physical  | Get-DNSClientServerAddress -AddressFamily IPv4

Open in new window


If the remote computers also have PowerShell 3 or newer you can use CIM sessions for remoting:
$cimWS1 = New-CimSession -ComputerName WS1
Get-NetAdapter -Physical -CimSession $cimWS1 | get-DNSClientServerAddress -AddressFamily IPv4 -CimSession $cimWS1

Open in new window


For PowerShell v2 (Windows 7) you'll have to use WMI
Avatar of Anagkazo

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for Anagkazo's comment #a41489249

for the following reason:

the script works for multiple remote machines