Wednesday, September 12, 2012

Powershell script to extract logon times from an imported user .csv file


Powershell script to extract logon times from an imported user .csv file

Create the following .csv file. The top column is labeled name, this is the variable used by powershell and then the user accounts are put underneath like so (see Figure 1)


Figure 1
 
Download powershell cmdlets
 
Run the following in quest powershell cmdlets app.
import-csv c:\chris.csv | Get-QADUser -id {$_.name} | select name,LastLogonTimestamp | export-csv c:\userlist.csv
 
$_.name refers to the column name “name” in figure1
 
The out put should look something like the below see figure 2
 
Figure 2