Link to home
Start Free TrialLog in
Avatar of Albert Widjaja
Albert WidjajaFlag for Australia

asked on

How to get the DNS of domain joined server from a list or specific OU ?

Hi Folks,

I'm about to decommission one of the old server which is currently serving as DNS server in my Data Center.
Most or lots of the legacy servers in my AD domain got the static DNS pointing to this server. So how can I get the list of the server with its DNS settings in a CSV format ?

Example:
Server name, DNS1, DNS2

Thanks.
Avatar of footech
footech
Flag of United States of America image

Although it's possible to get this information, if the plan is to replace this server with a new one, why don't you just stand up the new server with the same IP?  Then you don't have to change any config.
SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Albert Widjaja

ASKER

Because. New server is already running as new DC & DNS integrated while the old server is still running as the Win 2003 AD DC DNS box
Thanks Will, I'll give it a try in the office on Monday.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Will.

@Footech: May I know what's your script does in Line 1 and Line 8 ? Does it change the statically assigned DNS server into 10.10.0.1 ?
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Will:

Somehow the script failed to get the list of current server from specific OU and its DNS server into the Excel spreadsheet:

$Computers = Get-ADComputer -Filter * -SearchBase "OU=Production Servers,OU=Servers,DC=Domain,DC=com"
ForEach ($Computer in $Computers) {
	Get-WMIObject -class Win32_NetworkAdapterConfiguration | ? {$_.IPAddress -notlike $Null} | select $Computer.Name , IPAddress, DNSServerSearchOrder | Export-csv "C:\TEMP\DNSIP.csv" -Append
} 

Open in new window


Error code below:
Export-csv : Cannot append CSV content to the following file: C:\TEMP\DNSIP.csv. The appended object does not have a property that corresponds to the following column: 
PRODExcMbx01-VM. To continue with mismatched properties, add the -Force parameter, and then retry the command.
At C:\Users\Administrator\AppData\Local\Temp\4c40dff4-c8ba-4ab3-ad94-1e68d0c43a96.ps1:6 char:151
+ ... rSearchOrder | Export-csv "C:\TEMP\DNSIP.csv" -Append
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (PRODExcMbx01-VM:String) [Export-Csv], InvalidOperationException
    + FullyQualifiedErrorId : CannotAppendCsvWithMismatchedPropertyNames,Microsoft.PowerShell.Commands.ExportCsvCommand

Open in new window


and the result of the CSV is shown below:
#TYPE Selected.System.Management.ManagementObject
"PRODExcMbx01-VM","IPAddress","DNSServerSearchOrder"
,"System.String[]","System.String[]"

Open in new window

thanks !
Will's needed the -ComputerName parameter for the Get-WmiObject command.