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

powershell

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
0
Lidka
Asked:
Lidka
  • 4
  • 3
1 Solution
 
SubsunCommented:
Try this..
The script make use of Quest AD Cmdlets
Ref : http://www.quest.com/powershell/activeroles-server.aspx

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
 }
Else{
 Write-Host "$_ not reachable"
 $_ | Select @{N="Server";e={$_}},IP,lastLogonTimestamp,Location
 }
} | Export-Csv C:\report.csv -NoTypeInformation

Open in new window

0
 
LidkaAuthor Commented:
I have a list of computers in a text file. How can I get the lastlogontimestamp on them and expoert them to csv file
0
 
SubsunCommented:
Did you try my script?
0
Worried about phishing attacks?

90% of attacks start with a phish. It’s critical that IT admins and MSSPs have the right security in place to protect their end users from these phishing attacks. Check out our latest feature brief for tips and tricks to keep your employees off a hackers line!

 
LidkaAuthor Commented:
yes thank you it works great, but it did not give me anything except the dead machines list
0
 
SubsunCommented:
Do you have anything in result file C:\report.csv?
0
 
LidkaAuthor Commented:
only name of servers nothing else
0
 
SubsunCommented:
What if you run
Get-QADComputer Servername -IncludedProperties lastLogonTimestamp,Location
replace Servername  with the actual server name in your list..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Improved Protection from Phishing Attacks

WatchGuard DNSWatch reduces malware infections by detecting and blocking malicious DNS requests, improving your ability to protect employees from phishing attacks. Learn more about our newest service included in Total Security Suite today!

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