Login | |
|
 |
RE: Retrieve the Computer lastlogintimestamp? - 10/8/2008 2:03:56 AM
|
|
 |
|
| |
SAPIENScripter
Posts: 276
Score: 2
Joined: 11/1/2006
From: SAPIEN Technologies
Status: offline
|
You will need some method of getting the computer object from your domain and then a method of converting the lastlogon value to a meaningful date. Overall your process can look like this: get-content c:\list.txt | foreach { My-Function $_ } | out-file $file If your list has the complete DN, that simplifies things. Can you use the Quest AD cmdlets? That too will simplify things. The real challenge here is the My-Function piece. If you use ADSI to get the object , you'll need to convert the lastlogon value. This function should help with that: Function Get-UTCAge { #get date time of the last password change Param([int64]$Last=0) if ($Last -eq 0) { write 0 } else { #clock starts counting from 1/1/1601. [datetime]$utc="1/1/1601" #calculate the number of days based on the int64 number $i=$Last/864000000000 #Add the number of days to 1/1/1601 #and write the result to the pipeline write ($utc.AddDays($i)) } } # end Get-UTCAge function
_____________________________
Jeffery Hicks Windows PowerShell MVP SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com Follow Me: http://www.twitter.com/JeffHicks
|
|
| |
|
|
|
|
|