none
Script to Get DNS configuration of Remote Windows servers RRS feed

  • Question

  • Hi,

    I am writing a Script in PowerShell, to obtain the DNS Configurations of remote Windows servers.

    I am reading the server name from a text file.

    I want to use the NetIPConfiguration command in the script and then store the output in a file.

    What is the WmiObject class for NetIPConfiguration ? or any script for the same would be great.

     

    Wednesday, May 15, 2019 11:26 AM

All replies

  • You can try using Get-NetIPConfiguration along with Invoke-Command

    If you find that my post has answered your question, please mark it as the answer. If you find my post to be helpful in anyway, please click vote as helpful. (99,108,97,121,109,97,110,50,64,110,121,99,97,112,46,114,114,46,99,111,109|%{[char]$_})-join''

    Wednesday, May 15, 2019 12:43 PM
  • https://www.petri.com/manage-network-adapters-powershell-addressing-configuration-info
    Wednesday, May 15, 2019 12:48 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Thursday, May 16, 2019 12:11 PM
    Moderator
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee



    Just do it.

    Monday, May 20, 2019 6:50 AM
    Moderator
  • You can use below script to get ipconfig of all listed servers in CSV file and then filter relevant information

    $servernames = @(Import-Csv "C:\servers.csv")
    $outarray = @()
    foreach ( $servername in $servernames )
    {
    $nics = Get-WMIObject Win32_NetworkAdapterConfiguration -computername $servername.server |where{$_.IPEnabled -eq “TRUE”} | select DNShostname,ipaddress,dnsserversearchorder,fullDNSregistrationenabled
    Foreach($NIC in $NICs) {
    $outarray += New-Object PSObject -Property @{
    Servername = $nic.DNShostname
    IPAddress = [string]$nic.ipaddress
    Dnsserversearchorder = [string]$nic.dnsserversearchorder
    FullDNSregistrationenabled  = $nic.fullDNSregistrationenabled
    }}}$outarray |select Servername,ipaddress,Dnsserversearchorder,FullDNSregistrationenabled | Export-CSV C:\nic.csv -NTI

    Monday, May 20, 2019 7:09 AM
  • The script currently changes both the Primary as well as Secondary DNS servers for the server. How can I change only the Primary DNS server and leave the Secondary as it is for the time being ??

    Monday, June 24, 2019 6:39 AM
  • You can only set all dns servers using an array.  Get the current servers and alter the array tio your liking.


    \_(ツ)_/

    Monday, June 24, 2019 12:16 PM
    Moderator