Get-ADUser - 属性不为所有用户返回 PasswordNeverExpires

Get-ADUser -Properties not returning PasswordNeverExpires for all users

我正在尝试列出所有设置了 PasswordNeverExpires 标志的用户。

如果我用

Get-ADUser

我得到了我域中所有用户的列表,以及大量默认属性。

如果我用

Get-ADUser -Filter * -Properties Name | Format-Table -Property Name -AutoSize

我还得到了我域中所有用户名的列表,作为 table。

当我使用

Get-ADUser -Filter * -Properties Name,PasswordNeverExpires | Format-Table -Property Name,PasswordNeverExpire

我得到一个包含完整用户名列表的 table,但只有以下帐户在 PasswordNeverExpires 列中有 TrueFalse

Guest
krbtgt
Administrator
SBSMonAcct
Network Administrator
<MyDomainAdminAccount>
SPSearch
<AnAdministratorAccountForOneOfOurSoftwareVendors>
<AnAccountThatWasCopiedFromTheDomainAdministratorAccount>
<AnotherAccountCopiedFromTheDomainAdministratorAccount>

table 中的所有其他 items/usernames 具有 empty/blank/non-existent 值。

我也试过了

Get-ADUser -LDAPFilter "(&(!userAccountControl:1.2.840.113556.1.4.803:=2)(userAccountControl:1.2.840.113556.1.4.803:=65536))"

但那只是 returns

<MyDomainAdminAccount>
SPSearch

为什么 PasswordNeverExpires 标志没有被所有用户选中?谢谢。

PasswordNeverExpires 是根据 userAccountControl 属性计算的。

搜索设置了该标志的用户的最快方法可能如下:

Get-ADUser -LDAPFilter "(userAccountControl:1.2.840.113556.1.4.803:=65536)" -Properties PasswordNeverExpires

有关使用按位过滤器进行搜索的详细信息,请参阅 the documentation。 65536 (0x10000) 对应于 ADS_UF_DONT_EXPIRE_PASSWD 位位置,因此此 LDAP 搜索过滤器仅搜索设置了该标志的帐户。

嗯,你的第三行拉 属性 "PasswordNeverExpires" 但选择 "PasswordNeverExpire"。如果这只是您问题中的错字,请无视。如果没有,那就是你的答案。 :-)