header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

We have a new sponsor!  Introducting Pragma Systems.  See the home page for details.

convert lastlogon value..
Last Post 15 Jul 2010 10:37 AM by Shay. 3 Replies.
Printer Friendly
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Resolved
destnUser is Offline
New Member
New Member
Posts:6
Avatar

--
15 Jul 2010 10:09 AM  
I have following commandline: Get-ADUser -filter * -SearchScope Subtree -SearchBase "ou=sub,ou=sub,ou=sub,DC=domain,DC=com" | Get-ADObject -Properties lastlogon | Select-Object Name,lastlogon I do get the lastlogon timestamp, but in unreadable format. The conversion should be something like: [DateTime]::FromFileTime($lastlogon) But how do I implement this on my commandline?
ShayUser is Offline
Veteran Member
Veteran Member
Posts:1140
Avatar

--
15 Jul 2010 10:21 AM Accepted Answer  
Get-ADUser -filter * -Properties lastlogon -SearchScope Subtree -SearchBase "ou=sub,ou=sub,ou=sub,DC=domain,DC=com" | select Name,@{n='lastlogon';e={[DateTime]::FromFileTime($_.lastlogon)}}

Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Community Toolbar
Twitter: @ShayLevy
destnUser is Offline
New Member
New Member
Posts:6
Avatar

--
15 Jul 2010 10:28 AM  
Great!

For future use, could you, in brief, explain following line:

@{n='lastlogon';e={[DateTime]::FromFileTime($_.lastlogon)}}

@{} => I guess this is a scriptblock that needs execution first?

but the:

n='lastlogon';e={}

is hard to understand.
ShayUser is Offline
Veteran Member
Veteran Member
Posts:1140
Avatar

--
15 Jul 2010 10:37 AM  
Check this tip:

http://technet.microsoft.com/en-us/library/ff730948.aspx

Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Community Toolbar
Twitter: @ShayLevy
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 footer
footer