我发现一个脚本来获取AD组及其成员。 我工作正常,但突然停止工作,并给出了一个错误。
在Win2008r2中使用PowerShell列出所有组及其成员
$Groups = Get-ADGroup -Properties * -Filter * -SearchBase "OU=Groups,DC=corp,DC=ourcompany,DC=Com" Foreach($G In $Groups) { Write-Host $G.Name Write-Host "-------------" $G.Members }
错误
Get-ADGroup : The supplied distinguishedName must belong to one of the following partition(s): 'DC=AIA,DC=BIZ , CN=Configuration,DC=AIA,DC=BIZ , CN=Schema,CN=Configuration,DC=AIA,DC=BIZ , DC=ForestDnsZon es,DC=AIA,DC=BIZ , DC=DomainDnsZones,DC=AIA,DC=BIZ'. At C:\Users\zai_shanda\Desktop\adgroup.ps1:1 char:22 + $Groups = Get-ADGroup <<<< -Properties * -Filter * -SearchBase "AIA.BIZ/AIA/New Zealand/ZAI/Groups/General" + CategoryInfo : InvalidArgument: (:) [Get-ADGroup], ArgumentException + FullyQualifiedErrorId : The supplied distinguishedName must belong to one of the following partition(s): 'DC=AIA,DC=BIZ , CN=Configuration,DC=AIA,DC=BIZ , CN=Schema,CN=Configuration,DC=AIA,DC=BIZ , DC=ForestDnsZones,DC=AIA,DC=BIZ , DC=DomainDnsZones,DC=AIA,DC=BIZ'.,Microsoft.ActiveDirectory.Management.Commands.GetADGroup
可以请你帮忙什么是错的?
看到错误,您没有使用searchbase命令的名称,您需要用"AIA.BIZ/AIA/New Zealand/ZAI/Groups/General"专有名称"AIA.BIZ/AIA/New Zealand/ZAI/Groups/General"replace"AIA.BIZ/AIA/New Zealand/ZAI/Groups/General" 。 所以就像"DC=AIA,DC=BIZ,OU=AIA,OU=New Zealand,OU=ZAI,OU=Groups,OU=General"
请注意,我的DistinguishedName可能是错误的,你应该检查自己find你是基于你的search库的基础上,并直接复制它,以确保你没有得到任何错误。