Powershell script to perform nslookup on multiple servers

I would like to perform nslookup on multiple servers using powershell script.

I would also like to get the same for ping
Kailash KapalSenior ConsultantAsked:
Who is Participating?
 
QlemoConnect With a Mentor Batchelor, Developer and EE Topic AdvisorCommented:
Are we on W2012 R2/W8.1 or later? Those allow for new cmdlets making things easy:
Get-Content C:\Temp\EE\Servers.txt |
  % {
    Resolve-DnsName $_ -EA SilentlyContinue 
    if (!$?) { [PsCustomObject] @{ Name = $_; IP4Address = '' } }
  } |
  Select Name, IP4Address |
  Export-Csv -NoType C:\Temp\EE\DNSLookups.csv

Open in new window

0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Is this correct? You want to provide a list of server names, perform a DNS query for those (why?), then ping, and log the results?
0
 
Kailash KapalSenior ConsultantAuthor Commented:
You are correct. Only thing is I want to perform an nslookup and ping separately for a list of servers in a text file and pipe the output to a csv file. This is required so that I can fulfill any business requirements.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.