【问题标题】:Azure Active Directory Powershell ManagementAzure Active Directory Powershell 管理
【发布时间】:2022-01-04 15:21:20
【问题描述】:

代码:

$GroupObjectID = Get-AzureADGroup -SearchString "XXXXXXXXXXXXXXXXXXXX" | select ObjectId

Write-Output $GroupObjectID

Get-AzureADGroup -ObjectId $GroupObjectID

输出:

对象标识 -------- a0xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx

Get-AzureADGroup:执行 GetGroup 代码时出错: Request_BadRequest 消息:无效的对象标识符 '@{ObjectId=a0xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxx}'。请求编号: xxxxxxxxxxxxxxxxxxx 日期时间戳:2021 年 11 月 26 日,星期五 14:56:43 GMT HttpStatusCode:BadRequest HttpStatusDescription:Bad 请求 HttpResponseStatus:在 line:1 char:1 完成

  • 获取-AzureADGroup -ObjectId $DecryptGroupObjectID
  •   + CategoryInfo          : NotSpecified: (:) [Get-AzureADGroup], ApiException
      + FullyQualifiedErrorId : Microsoft.Open.AzureAD16.Client.ApiException,Microsoft.Open.AzureAD16.PowerShell.GetGroup
    

问题:write-output 语句返回给我一个 ObjectID,我将其存储并在下一行查询与此 objectid 匹配的组。我假设我存储了一个 system.object 而不是一个 system.String,但是我该如何解决这个问题呢?

【问题讨论】:

  • 你好 Daiter,如果我的回答对你有帮助,你可以接受它作为答案(点击答案旁边的复选标记,将其从灰色切换为填充。)。这对其他社区成员可能是有益的。谢谢
  • @RahulKumarShaw-MT 感谢您帮助我!

标签: azure-active-directory azure-powershell


【解决方案1】:

尝试使用以下 PowerShell 脚本并获得您正在寻找的预期输出

$GroupObjectID = Get-AzureADGroup -SearchString "'Merican Numero Uno"
Write-Output $GroupObjectID
Get-AzureADGroup -ObjectId $GroupObjectID.ObjectId 

$GroupObjectID = Get-AzureADGroup -SearchString "'Merican Numero Uno" |select ObjectId,DisplayName,Description
Write-Output $GroupObjectID
Get-AzureADGroup -ObjectId $GroupObjectID.ObjectId 

您的脚本无法运行的原因是因为脚本的第一行仅在变量中使用了objectID,并希望打印DisplayName。由于$GroupObjectID 变量具有三个不同的值,即ObjectIDDisplayNameDescription,因此您必须传递要显示的所有参数。

$GroupObjectID = Get-AzureADGroup -SearchString "XXXXXXXXXXXXXXXXXXXX" | select ObjectId

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-06-16
    • 2016-04-17
    • 1970-01-01
    • 1970-01-01
    • 2020-07-20
    • 1970-01-01
    • 2020-11-24
    • 2019-01-22
    相关资源
    最近更新 更多