# Get-ADuser 'LastLogon' empty, but ADSI Edit has information?

**URL:** <https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660>\
**Category:** PowerShell Help\
**Created:** [November 12, 2018, 8:21am UTC](https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660 "2018-11-12T08:21:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasonleech](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jasonleech](https://forums.powershell.org/u/jasonleech)\
**Post date:** [November 12, 2018, 8:21am UTC](https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660/1 "2018-11-12T08:21:19Z")

</div>

Hi all,

&nbsp;

I have been reuqested to report on last logins for users…I have tried Get-ADUser:

[pre]

get-aduser -filter {enabled -eq $True} -properties lastlogontimestamp, passwordlastset, passwordneverexpires |ft Name, passwordlastset, passwordneverexpires, @{Name=“Last Logon”;Expression={([datetime]::FromFileTime($\_.LastLogonTimeStamp))}} | Out-File -file “$ADReports$D Password and Logons $Date.txt”

[/pre]

but alot of the entries are blank. When I query the user specifically, LastLogonTimeStamp is empty…however, if I use ADSIEdit, and browse to the correct OU, I can see there is data stored for that user? There’s only one Domain Controller aswell, so can’t work out why I’m not reproducing the same result with Get-ADuser…is there anything I need to synchronise for the ADSIEdit information to populate with Get-ADuser?

&nbsp;

Thanks

&nbsp;

Jason

---

<div class="post-metadata">

**Author:** ![Olaf](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/olaf/32/992_2.png) [@Olaf](https://forums.powershell.org/u/Olaf)\
**Post date:** [November 12, 2018, 10:16am UTC](https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660/2 "2018-11-12T10:16:13Z")

</div>

There are different “lastLogon” attributes. Maybe you’re using the wrong one. See the answer from Richard Mueller in this thread. It might help you.

[https://social.technet.microsoft.com/Forums/office/en-US/eba1b4da-dc88-42db-b596-fdfb8f8222db/powershell-getaduser-question?forum=ITCG#e1657a61-6979-4f3d-bf0c-c4d2d17dd4ed](https://social.technet.microsoft.com/Forums/office/en-US/eba1b4da-dc88-42db-b596-fdfb8f8222db/powershell-getaduser-question?forum=ITCG#e1657a61-6979-4f3d-bf0c-c4d2d17dd4ed)

Edit: If I understand it right you should use the attribute lastLogon and you will have to “calculate” it to make it human readable. Something like this should work actually

```
Get-ADUser -Identity “sAMAccountName” -Properties lastLogon,LastLogonDate |
Select-Object *,@{Name=‘LastLogonReadable’;Expression={ [DateTime]::FromFileTime($_.LastLogon) }}
```

---

<div class="post-metadata">

**Author:** ![jasonleech](https://avatars.discourse-cdn.com/v4/letter/j/65b543/32.png) [@jasonleech](https://forums.powershell.org/u/jasonleech)\
**Post date:** [November 12, 2018, 10:41am UTC](https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660/3 "2018-11-12T10:41:49Z")

</div>

hi, thanks Olaf, no luck I’m afraid…just tested on a user:

&nbsp;

[pre]

DistinguishedName :  
GivenName : Mark  
LastLogonDate :  
Name :  
ObjectClass : user  
ObjectGUID : 03382a95-c4fb-4cd3-b489-a1dc9d00748b  
SamAccountName :  
SID : S-1-5-21-2103417339-1537711377-xxxxxxx  
Surname :  
UserPrincipalName :  
Enabled :  
PropertyNames : {DistinguishedName, GivenName, LastLogon, LastLogonDate…}  
AddedProperties : {}  
RemovedProperties : {}  
ModifiedProperties : {}  
PropertyCount : 10  
LastLogonReadable : 01/01/1601 00:00:00

[/pre]

however, if i go through ADSIEdit, I have entries for LastLogon and LastLogonTimestamp for the same user?

---

<div class="post-metadata">

**Author:** ![donj](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/donj/32/137_2.png) [@donj](https://forums.powershell.org/u/donj)\
**Post date:** [November 12, 2018, 11:55am UTC](https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660/4 "2018-11-12T11:55:17Z")

</div>

Bear in mind that LastLogon is not replicated - it’s per-DC. So it’s possible that ADSIEdit is connecting to a DC that has the data, which would be the one the user is authenticating to, but your command is connecting to something different.

LastLogonTimestamp replicates, but on a “slow” track. It can take time to make it to every DC.

It’s worth reading up on how those two properties work, as they’re pretty tricky to actually worth with due to the way AD itself is built.

&nbsp;

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:33pm UTC](https://forums.powershell.org/t/get-aduser-lastlogon-empty-but-adsi-edit-has-information/11660/5 "2024-05-16T20:33:43Z")

</div>


