0

我编写了以下脚本来返回域中所有空组织单位的名称。

我希望脚本还通过计算返回的行数来告诉我最后空 OU 的总数。我尝试将 分配$array给,并在脚本末尾添加或的New-Object各种版本,但都返回。$array.count| Measure-Object0

Get-ADOrganizationalUnit -Filter * |
foreach {
    $o = Get-ADObject -filter * -searchbase $_.distinguishedname -searchscope 1
    $total = ($o | Measure-Object).Count 
    New-Object psobject -Property @{
        Name=$_.distinguishedname
        } |
        where-object {$total -le "0"}
    }
4

1 回答 1

2
$ou = Get-ADOrganizationalUnit -Filter * | 
Where-Object { -not (Get-ADObject -SearchBase $_.DistinguishedName -Filter * -SearchScope OneLevel) }


# get the count
$ou|measure

$list OUs
$ou 
于 2013-07-03T12:27:21.800 回答