我正在尝试比较两个数组,但是当我尝试同时调用它们时,这些数组没有注册。
$1 = Get-ADUser -SearchBase “OU=New,dc=contoso,dc=com” -Filter * -Properties * | select -Unique Department
$2 = Get-ADOrganizationalUnit -Filter * | select Name
$1
输出符合预期:
Department
----------
Officer
当我将$ 1更改为$ 2时,也会得到您期望的结果:
Name
----
New
Officer
但是当我同时添加两个变量时:
$1 = Get-ADUser -SearchBase “OU=New,dc=contoso,dc=com” -Filter * -Properties * | select -Unique Department
$2 = Get-ADOrganizationalUnit -Filter * | select Name
$1
Write-Host "------------------------------------------------------"
$2
它仅输出以下内容:
------------------------------------------------------
Department
----------
Officer