Posted on 2013-01-23
Last Modified: 2013-01-25
I have a list in the text file by a computer name (400 names)
I need to get all IP from this list and the last logon time and location if it is possible using a powershell
Question by:Lidka
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
LVL 40

Accepted Solution

Subsun earned 500 total points
ID: 38810544
Try this..
The script make use of Quest AD Cmdlets
Ref :

C:\server.txt is the input file with server names..

GC C:\server.txt | % {
$Ping = Test-Connection $_ -ErrorAction SilentlyContinue
If ($Ping){
Get-QADComputer $ping[0].Address -IncludedProperties lastLogonTimestamp,Location | 
Select @{N="Server";e={$ping[0].Address}},@{N="IP";e={$ping[0].IPV4Address.IPAddressToString}},lastLogonTimestamp,Location
 Write-Host "$_ not reachable"
 $_ | Select @{N="Server";e={$_}},IP,lastLogonTimestamp,Location
} | Export-Csv C:\report.csv -NoTypeInformation

Open in new window


Author Comment

ID: 38811981
I have a list of computers in a text file. How can I get the lastlogontimestamp on them and expoert them to csv file
LVL 40

Expert Comment

ID: 38811996
Did you try my script?
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.


Author Comment

ID: 38814269
yes thank you it works great, but it did not give me anything except the dead machines list
LVL 40

Expert Comment

ID: 38814289
Do you have anything in result file C:\report.csv?

Author Comment

ID: 38814764
only name of servers nothing else
LVL 40

Expert Comment

ID: 38814788
What if you run
Get-QADComputer Servername -IncludedProperties lastLogonTimestamp,Location
replace Servername  with the actual server name in your list..

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
In this post we will be converting StringData saved within a text file into a hash table. This can be further used in a PowerShell script for replacing settings that are dynamic in nature from environment to environment.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

691 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