# Odd date behavior with Get-ADUser

**URL:** <https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441>\
**Category:** PowerShell Help\
**Created:** [November 19, 2019, 3:23pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441 "2019-11-19T15:23:07Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-mongelluzzo](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@john-mongelluzzo](https://forums.powershell.org/u/john-mongelluzzo)\
**Post date:** [November 19, 2019, 3:23pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/1 "2019-11-19T15:23:07Z")

</div>

This command produces the output of an ID and the date the password will expire.

```
Get-ADUser -ID MyID –Properties * | Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
```

The output is as follows and is incorrect:

```
Displayname ExpiryDate
----------- ----------`
John M 12/31/1600 7:00:00 PM
```

However if I specify the property explicitly in with the -Props, the correct information is produced:

```
Get-ADUser -ID MyID –Properties DisplayName, msDS-UserPasswordExpiryTimeComputed | Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
```

```
Displayname ExpiryDate
----------- ----------
John M 12/8/2019 6:59:55 AM
```

Any ideas? I am fine with using the correct properties in the command, just curious why the wildcard \* produces the wrong result.

---

<div class="post-metadata">

**Author:** ![js2010](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@js2010](https://forums.powershell.org/u/js2010)\
**Post date:** [November 19, 2019, 3:49pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/2 "2019-11-19T15:49:26Z")

</div>

Looks like properties \* doesn’t return msDS-UserPasswordExpiryTimeComputed.

---

<div class="post-metadata">

**Author:** ![aapeli-hietikko](https://avatars.discourse-cdn.com/v4/letter/a/47e85d/32.png) [@aapeli-hietikko](https://forums.powershell.org/u/aapeli-hietikko)\
**Post date:** [November 19, 2019, 3:52pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/3 "2019-11-19T15:52:45Z")

</div>

This was a cool question! I’ve never had problem with this as I try to avoid using \*, but!  
It looks like the \* is pre-defined with 156 properties when there is actually more. I found this script to bring all the types

[pre]

$properties = Get-ADObject -SearchBase (Get-ADRootDSE).SchemanamingContext -Filter {name -eq “User”} -Properties MayContain,SystemMayContain |  
Select-Object @{name=“Properties”;expression={$_.maycontain+$_.systemmaycontain}} |  
Select-Object -ExpandProperty Properties

$properties.count  
165

$bom = get-aduser myuser -prop \*  
($bom | gm | Where {$\_.membertype -eq ‘property’}).count  
156

[/pre]

And this seems to be a rabbit hole. Needs to be dig deeper. Someone wiser could come to rescue me 🙂

---

<div class="post-metadata">

**Author:** ![john-mongelluzzo](https://avatars.discourse-cdn.com/v4/letter/j/73ab20/32.png) [@john-mongelluzzo](https://forums.powershell.org/u/john-mongelluzzo)\
**Post date:** [November 19, 2019, 4:12pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/4 "2019-11-19T16:12:24Z")

</div>

so simple

---

<div class="post-metadata">

**Author:** ![tonyd](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/tonyd/32/1041_2.png) [@tonyd](https://forums.powershell.org/u/tonyd)\
**Post date:** [November 20, 2019, 4:49pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/5 "2019-11-20T16:49:23Z")

</div>

Interesting. I had always assumed when that funky date was returned, it implied the user had never logged in. In my environment, this assumption is accurate. Could that be your case as well?

---

<div class="post-metadata">

**Author:** ![p0wd3r](https://avatars.discourse-cdn.com/v4/letter/p/b5a626/32.png) [@p0wd3r](https://forums.powershell.org/u/p0wd3r)\
**Post date:** [November 21, 2019, 1:15pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/6 "2019-11-21T13:15:34Z")

</div>

`Search-ADAccount -AccountExpiring | select name,AccountExpirationDate`

Use that instead. I had to adapt a lot of scripts after some PS update, I think it came out when Server 2012R2 did, but I forget the exact time.

---

<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:31pm UTC](https://forums.powershell.org/t/odd-date-behavior-with-get-aduser/13441/7 "2024-05-16T20:31:02Z")

</div>


