Solved

powershell

Posted on 2013-01-23
7
250 Views
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
0
Comment
Question by:Lidka
  • 4
  • 3
7 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
Comment Utility
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
 

Author Comment

by:Lidka
Comment Utility
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
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
Did you try my script?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:Lidka
Comment Utility
yes thank you it works great, but it did not give me anything except the dead machines list
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
Do you have anything in result file C:\report.csv?
0
 

Author Comment

by:Lidka
Comment Utility
only name of servers nothing else
0
 
LVL 40

Expert Comment

by:Subsun
Comment Utility
What if you run
Get-QADComputer Servername -IncludedProperties lastLogonTimestamp,Location
replace Servername  with the actual server name in your list..
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 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

12 Experts available now in Live!

Get 1:1 Help Now