Solved

Powershell script to perform nslookup on multiple servers

Posted on 2016-10-06
3
12 Views
Last Modified: 2016-10-29
I would like to perform nslookup on multiple servers using powershell script.

I would also like to get the same for ping
0
Comment
Question by:Kailash Kapal
  • 2
3 Comments
 
LVL 68

Expert Comment

by:Qlemo
ID: 41836163
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
 

Author Comment

by:Kailash Kapal
ID: 41842365
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
 
LVL 68

Accepted Solution

by:
Qlemo earned 500 total points
ID: 41842443
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

I use more than 1 computer in my office for various reasons. Multiple keyboards and mice take up more than just extra space, they make working a little more complicated. Using one mouse and keyboard for all of my computers makes life easier. This co…
Today, still in the boom of Apple, PC's and products, nearly 50% of the computer users use Windows as graphical operating systems. If you are among those users who love windows, but are grappling to keep the system's hard drive optimized, then you s…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now