使用Get-ADGroups和Get-ADGroupMembers时,我遇到了一个奇怪的问题
此行正常(无问题)
$searchFilter = "OU=Projects,DC=my,DC=lab"
Get-ADGroup -Filter * -Properties * -SearchBase $distinguishedName | Get-ADGroupMember | Where-Object {$_.objectClass -eq "user"} | Get-ADUser | ft Name, SamAccountName, Enabled
但是这个块不起作用
$groups = Get-ADGroup -Filter * -Properties * -SearchBase $distinguishedName
foreach ($g in $groups) {
Write-Host "Group:" $g.CN "(" $g.DistinguishedName ")"
Get-ADGroupMember -Identity $g.DistinguishedName -Debug -Verbose | Where-Object {$_.objectClass -eq "user"} | Get-ADUser | ft Name, SamAccountName, Enabled
}
返回以下异常
Microsoft.ActiveDirectory.Management.ADException: An operations error occurred ---> System.ServiceModel.FaultException`1[schemas.microsoft.com._2008._1.ActiveDirectory.CustomActions.GetADGroupMemberFault]: Active Directory returned an error processing the operation.
任何人都有任何想法?
答案 0 :(得分:0)
你的第二个适合我。仔细检查您传递给-SearchBase
的$ distinguishedName值。
我注意到你定义了$ searchFilter,但你实际上从未引用它。这是一个错字吗?