VMware Cloud Community
NeenaJim
Enthusiast
Enthusiast

DNS

Hello,

Can someone please tell me:

I have a text file called 'Server_IP' and in that sheet it has all the IPs.

Is there anyway I can script and get the DNS names by doing nslookup of that IPs and get the result in excel sheet (Can save it in D drvie) like below:

(Column A)     (Column B)

Server IP         Server Name

Tags (1)
Reply
0 Kudos
2 Replies
scott28tt
VMware Employee
VMware Employee

Isn’t your question straight PowerShell rather than PowerCLI? It seems you’re just looking to extract records from your DNS server, whatever that is...


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
LucD
Leadership
Leadership

You could do something like this

Get-Content -Path .\file.txt |
ForEach-Object -Process {
    New-Object -TypeName PSObject -Property @{
        IP = $_
        HostName = (Resolve-DnsName -Name $_).NameHost
    }
| Export-Csv -Path D:\report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference