如果我有以下代码,我发现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