Get-ADUserResultantPasswordPolicy 返回有关找不到容器的错误

问题描述 投票:0回答:1

我正在尝试编写一些 PowerShell,但 cmdlet 返回错误,我不太明白其原因。

cmdlet

Get-AdUserResultantPasswordPolicy
的使用方式如下:

Get-AdUserResultantPasswordPolicy -Identity <redacted>

它返回错误(对编辑表示歉意)

PS C:\> Get-ADUserResultantPasswordPolicy -Identity <redacted>
Get-ADUserResultantPasswordPolicy : Cannot find an object with identity: 'CN=<redacted>y, CN=Password Settings Container,CN=System,DC=<redacted>,DC=<redacted>,DC=<redacted>,DC=<redacted>' under: '<redacted>'.
At line:1 char:1
+ Get-ADUserResultantPasswordPolicy -Identity <redacted>
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (CN=<redacted>,DC=<redacted>,DC=<redacted>:String) [Get-ADUserResultantPasswordP
   olicy], ADIdentityNotFoundException
    + FullyQualifiedErrorId : ADGetPropertiesCmdletBase:WritePropertiesToOutput,Microsoft.ActiveDirectory.Management.C  ommands.GetADUserResultantPasswordPolicy

密码政策绝对存在。我已通过 Active Directory 管理中心和 ADSIEdit 确认了这一点

有人遇到过这个吗?

powershell active-directory
1个回答
0
投票

如下所述,身份参数指定 AD 用户,而不是密码策略,因此应提供接近身份的用户,例如:

获取 ADUserResultantPasswordPolicy -身份 BobKe

https://learn.microsoft.com/en-us/powershell/module/activedirectory/get-aduserresultantpasswordpolicy?view=windowsserver2022-ps

-身份 通过提供以下属性值之一来指定 Active Directory 用户对象。括号中的标识符是属性的 LDAP 显示名称。该参数可接受的值为:

一个响亮的名字 GUID(对象GUID) 安全标识符(objectSid) SAM 帐户名称 (sAMAccountName)

© www.soinside.com 2019 - 2024. All rights reserved.