• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 73
  • Last Modified:

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
0
Kailash Kapal
Asked:
Kailash Kapal
  • 2
1 Solution
 
QlemoC++ DeveloperCommented:
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 KapalIdM Project Lead (India Ops)Author 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
 
QlemoC++ DeveloperCommented:
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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now