Scenario: You want to determine the IP Address and PTR record for each Exchange Server in your environment. Below is the script I used. This will query for DNS and put the results into a table called $final.
Script:
$servers = get-exchangeserver ex2013* | Where AdminDisplayVersion -like *15* $final = @() $Servers | %{ write-host $_.Name $Name = ([System.Net.Dns]::GetHostEntry("$_")).HostName; $Address = ([System.Net.Dns]::GetHostEntry("$_")).AddressList; $PTR = ([System.Net.Dns]::GetHostByAddress($Address)).HostName $returnobj = new-object psobject $returnobj |Add-Member -MemberType NoteProperty -Name "ServerName" -Value $Name $returnobj |Add-Member -MemberType NoteProperty -Name "IPAddress" -Value $Address $returnobj |Add-Member -MemberType NoteProperty -Name "PTR" -Value $PTR $final += $returnObj $Name = $null $address = $null $ptr = $null } $final