Solved

Powershell script to perform nslookup on multiple servers

Posted on 2016-10-06
3
13 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
USB ports are not working 18 104
Recover data from failed SSD SanDisk Ultra II 4 83
XP driver for Dell Color MFP H625cdw printer needed 7 149
Internet Connection Util 8 81
The article will include the best Data Recovery Tools along with their Features, Capabilities, and their Download Links. Hope you’ll enjoy it and will choose the one as required by you.
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…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

930 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

10 Experts available now in Live!

Get 1:1 Help Now