Share via


Poweshell command to pull the CNames out of list of Host name.

Question

Thursday, December 18, 2014 1:10 PM

Hi shiva,

Please try below commands and let me know

Get All the records:

Get-DnsServerResourceRecord -ZoneName abc.com -ComputerName
server001

 

 

Get all the records of specific type (A, AAAA, CNAME)

Get-DnsServerResourceRecord -ZoneName abc.com -ComputerName
server001 -RRType A   

Get-DnsServerResourceRecord -ZoneName abc.com -ComputerName
server001 -RRType CNAME   

Get-DnsServerResourceRecord -ZoneName abc.com -ComputerName
server001 -RRType AAAA

ADS/DNS/DHCP/RIS/GROUP POLICY/PowerShell/VMware/Esxi/Storage.

All replies (4)

Friday, December 19, 2014 7:48 AM | 1 vote

Hi Raj,

Thanks for your sharing =)

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]


Friday, December 19, 2014 3:42 PM

Hi AnnaWY,

Thank you so much,

 Just wanted to know,if have tried any PS cmd liner, which provides us CNames of the ip addresses.

 we have IPlists.txt we require output as CNames.

Regards,

Raj

[email protected]

ADS/DNS/DHCP/RIS/GROUP POLICY/PowerShell/VMware/Esxi/Storage.


Monday, December 22, 2014 2:55 AM

Hi Raj,

Please try the script below on DNS server:

$ips="ip1","ip2"
 foreach($ip in $ips){
 $fqdn = [System.Net.Dns]::GetHostbyAddress($ip)|select -ExpandProperty hostname #get fqdn from ip
 $new=$fqdn+"."
 Get-DnsServerResourceRecord -ZoneName "yourzonename" -RRType cname|where{($_.recorddata).hostNameAlias -eq $new}
}

Best Regards,

Anna Wang

Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Support, contact [email protected]


Monday, December 22, 2014 2:54 PM

Hi Anna Wang,

Thank you very much for reply and i will try out this and update it to you without fail.

Regards

Raj Navalgund

ADS/DNS/DHCP/RIS/GROUP POLICY/PowerShell/VMware/Esxi/Storage.