变量不起作用,我认为它们应该

时间:2019-04-19 19:04:00

标签: powershell active-directory

我正在尝试比较两个数组,但是当我尝试同时调用它们时,这些数组没有注册。

$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

0 个答案:

没有答案