Saturday, January 3, 2009

Get-QADComputer Lastlogintime

Get-QADComputer Lastlogintime                      

This code will give you the computers that have been inactive for 30 days:

$limit = (get-date).AddDays(-30).ToFileTime()
$filter = "(&(objectcategory=computer)(|(lastLogonTimestamp<=$limit)(!(lastLogonTimestamp=*))))" $inactivecomputers = Get-QADComputer -ldapFilter $filter -SizeLimit 0


It's faster than piping to where-object.


show the time stamp?



$limit = (get-date).AddDays(-30).ToFileTime()
$filter = "(&(objectcategory=computer)(|(lastLogonTimestamp<=$limit)(!(lastLogonTimestamp=*))))"

$inactivecomputers = Get-QADComputer -ldapFilter $filter -ip lastlogontimestamp -SizeLimit 0

$inactivecomputers | ft name,@{l="LastLogonTimeStamp";e={if($_.lastLogonTimestamp -ne $null){[DateTime]::FromFileTime([Int64]::Parse($_.lastLogonTimestamp))}} } -autosize


No comments: