我正在尝试运行一个简单的PowerShell命令let,该命令列出所有匹配名称条件的设备,并在下一步中将这些设备移动到选定的Azure组中。
我尝试过:
$result = Get-AzureADDevice -All $True -SearchString "LAP-BK" | ForEach-Object -Process {Add-AzureADGroupMember -ObjectId "25f94620-d850-4ec6-9476-050429d44926" -RefObjectId "$result.ObjectId"}
但是投掷失误。我还试着用
$result = Get-AzureADDevice -All $True -SearchString "LAP-BK" |Select-Object ObjectId
forEach ($item in $result)
{
Add-AzureADGroupMember -ObjectId "25f94620-d850-4ec6-9476-050429d44926" -RefObjectId "$item"
}
exit
错误多种多样,我收到的最后一个错误是:
Error occurred while executing AddGroupMember Code: Request_BadRequest Message: Invalid object identifier ' @{ObjectId=debb95af-9h1f-49d6-ad84-8438f9c99b10}'. RequestId: 6df36830-7708-4f6b-b836-cd065f5f60b1
1条答案
按热度按时间qltillow1#
try{} catch{}
块来查找此类拦截器,会更有帮助。