为什么Powershell不等待命令完成

时间:2019-09-17 15:03:35

标签: powershell

如果我有以下代码,我发现Powershell似乎没有等到Get-ADGroupMember完成。

$Groups = "Group1", "Group2"

foreach ($Group in $Groups) {
Get-ADGroupMember -Identity $Group -Recursive | Select Name
Write-Host "End of line"
}

从以上所述,我希望获得以下信息(考虑我的组具有相同的用户):

Mike Myers
Tim Sanders
Lucy Gray
End of line
Mike Myers
Tim Sanders
Lucy Gray
End of line

但是我得到了:

End of line
Mike Myers
Tim Sanders
Lucy Gray
Mike Myers
Tim Sanders
Lucy Gray
End of line

0 个答案:

没有答案