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
  • 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?
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.


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

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

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
Set OWA language and time zone in Exchange for individuals, all users or per database.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

911 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

24 Experts available now in Live!

Get 1:1 Help Now