【问题标题】:Get-ADUser -Properties not returning PasswordNeverExpires for all usersGet-ADUser -Properties 不为所有用户返回 PasswordNeverExpires
【发布时间】:2018-08-21 15:42:10
【问题描述】:

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

如果我使用

Get-ADUser

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

如果我使用

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

我还获得了我域中所有用户名的列表,以表格形式。

当我使用时

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

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

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

表中的所有其他项目/用户名都有空/空白/不存在的值。

我也试过

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

但这只会返回

<MyDomainAdminAccount>
SPSearch

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

【问题讨论】:

    标签: powershell active-directory passwords user-accounts


    【解决方案1】:

    PasswordNeverExpiresuserAccountControl 属性计算得出。

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

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

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

    【讨论】:

      【解决方案2】:

      嗯,您的第三行提取了属性“PasswordNeverExpires”,但选择了“PasswordNeverExpire”。如果这只是您问题中的错字,请忽略。如果没有,那么这就是你的答案。 :-)

      【讨论】:

        猜你喜欢
        • 2014-11-29
        • 2021-07-23
        • 2013-04-30
        • 2023-03-14
        • 2019-09-22
        • 2018-12-22
        • 1970-01-01
        • 2020-05-01
        • 1970-01-01
        相关资源
        最近更新 更多