Register
: :
Login
Home
Forums
Blogs
Podcast
Directories
Scripts
Downloads
Community
User Group Support
Learning Resources
We have a new sponsor! Introducting
Pragma Systems
. See the home page for details.
Unanswered
Active Topics
Forums
Search
Members
Forums
>
Using PowerShell
>
Active Directory
convert lastlogon value..
Last Post 15 Jul 2010 10:37 AM by
Shay
. 3 Replies.
Sort:
Oldest First
Most Recent First
Prev
Next
You are not authorized to post a reply.
Author
Messages
destn
New Member
Posts:6
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?
Shay
Veteran Member
Posts:1140
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
destn
New Member
Posts:6
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.
Shay
Veteran Member
Posts:1140
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.
PowerShellCommunity.org
--Community Announcements and Assistance
--Completely Unrelated
--User Groups
--Community Business
----Suggestion Box
Using PowerShell
--General PowerShell
--Books, Tools, and Videos
--Exchange Server
--Active Directory
--System Center Family
--Non-Microsoft Products
--SharePoint
--SQL Server
--Working with .NET
--Peer Review
--Testing, Testing...
PowerShell Development
--Cmdlet Development
--PSDrive Provider Development
--Hosting the Shell
Looking Ahead
--Using PowerShell v2.0
--Developing for PowerShell v2.0
Forums
>
Using PowerShell
>
Active Directory
Active Forums 4.1
Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008