none
LastLogonDate 12/31/1600 7:00:00 PM RRS feed

  • Question

  • I am running a script to retrieve user parameters in an OU, including the log on date, and some are coming back as 12/31/1600 7:00:00 PM. Any idea why?

    Get-ADUser -Filter * -SearchBase "OU=Admin Accounts,etc.,DC=com" -ResultPageSize 0 -Prop CN,ObjectClass,Name,UserPrincipalName,samaccountname,lastLogonTimestamp | Select CN,ObjectClass,Name,UserPrincipalName,samaccountname,lastLogonTimestamp,@{n="lastLogonDate";e={[datetime]::FromFileTime($_.lastLogonTimestamp)}}

    Thanks

    Tuesday, October 17, 2017 4:13 PM

Answers

  • Don't automatically convert to a timestamp using FromFileTime. If it's zero, don't output it.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, October 17, 2017 9:54 PM
    Moderator

All replies

  • That means the lastLogonTimestamp attribute is null (empty) for those accounts.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, October 17, 2017 4:22 PM
    Moderator
  • The "zero" date for LargeInteger datetime values is 12:00 am Jan. 1 1601, in UTC (Coordinated Universal Time). The value you see is local time, so your local time zone must be 5 hours before UTC.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, October 17, 2017 5:41 PM
    Moderator
  • Is there a script I can run to change the output?

    Tuesday, October 17, 2017 6:28 PM
  • Don't automatically convert to a timestamp using FromFileTime. If it's zero, don't output it.

    -- Bill Stewart [Bill_Stewart]

    Tuesday, October 17, 2017 9:54 PM
    Moderator
  • I test for zero. If zero output "Never", otherwise convert with FromFileTime, or similar.

    Richard Mueller - MVP Enterprise Mobility (Identity and Access)

    Tuesday, October 17, 2017 9:57 PM
    Moderator