accountExpires 属性不改变格式

accountExpires properties not changing format

所以我有一个衬里,return关于 AD 中所有用户的特定属性。

我的问题是 return"accountExpires" 字段保持空白,我不知道为什么。

如果我将脚本更改为仅 return 属性 未格式化的它可以工作,但它不是完全可读的。

如有任何帮助,我们将不胜感激。

Get-ADUser -Filter * -Properties * | Select Name,Enabled,whenCreated,whenChanged,@{N='accountExpires';E={[DateTime]::FromFileTime($_.accountExpires)}},@{N='LastLogon'; E={[DateTime]::FromFileTime($_.LastLogon)}}

ActiveDirectory 模块有一个对我来说很烦人的功能。他们没有在包含日期(例如 accountExpires)的字段中转换日期,而是提供了第二个 属性 具有类似的名称,其中包含转换后的值。

Get-ADUser -Filter * -Properties * | Select-Object AccountExpirationDate

这应该可以让您摆脱自己转换的需要。