PowerTip: Use PowerShell to Get DNS Settings


Summary: Use Windows PowerShell to retrieve local DNS server addresses.

Hey, Scripting Guy! Question With IPconfig, I used to pipe output to the FIND command to filter only DNS information.
          Is there a better way to do this in Windows Server 2012 R2?

Hey, Scripting Guy! Answer Use the Get-DnsClientServerAddress cmdlet:

Get-DnsClientServerAddress | Select-Object –ExpandProperty ServerAddresses

Comments (7)

  1. Tip: If you’re trying to query remote servers, use ‘Get-DNSClientServerAddress -CimSesssion ‘ rather then ‘invoke-command -ComputerName -ScriptBlock {Get-DNSClientServerAddress …}’.

    Invoke-command on the Get-DNSClientServerAddress commandlet doesn’t work as expected due to deserialization.

    See more here:
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/537dc7cc-3b37-41f9-a9a8-67a872b52e34/invokecommand-for-getnetipconfiguration-or-getdnsclientserveraddress-fails-with-serveraddress-is?forum=winserverpowershell

  2. Tip: If you’re trying to query remote servers, use ‘Get-DNSClientServerAddress -CimSesssion ‘ rather then ‘invoke-command -ComputerName -ScriptBlock {Get-DNSClientServerAddress …}’.

    Invoke-command on the Get-DNSClientServerAddress commandlet doesn’t work as expected due to deserialization.

    See more here:
    https://social.technet.microsoft.com/Forums/windowsserver/en-US/537dc7cc-3b37-41f9-a9a8-67a872b52e34/invokecommand-for-getnetipconfiguration-or-getdnsclientserveraddress-fails-with-serveraddress-is?forum=winserverpowershell

  3. SharePoint 2013 Administration Training in Hyd says:

    Wonderful information, your website gives the best and the most interesting information. Regards,
    SharePoint 2013 Administration Training in Hyderabad

  4. SharePoint 2013 Developer Training in Hyd says:

    Excellent information, I had come to know about your website from my friend, and let me tell you, your site gives the best and the most interesting information. Regards,

    SharePoint 2013 Developer Training in Hyderabad

  5. SharePoin 2013t Online Training in Hyderabad says:

    Great article …Thanks for your great information, the contents are quiet interesting. I will be waiting for your next post.
    http://khalil-kothia.com/">SharePoint 2013 Online Training in Hyderabad

  6. SharePoint 2013 Training Institutes in Hyd says:

    Great Article! Thanks for the nice collection of info…
    http://sharepointtraininginhyderabad.in/">SharePoint 2013 Training Institutes in Hyderabad

  7. tom says:

    How would you do this on server 2008?

Skip to main content