如何使用PowerShell获取Azure资源的对象ID

j8yoct9x  于 12个月前  发布在  Shell
关注(0)|答案(2)|浏览(107)

如何使用PowerShell小工具获取Azure资源的对象ID?
我尝试使用Get-AzureRmResource -ResourceName 'my-resource' | fl,但它失败的错误:Parameter set cannot be resolved using the specified named parameters
我还尝试使用Get-AzResource -Name 'my-resource',但它检索的信息中不包括对象ID。

gt0wga4j

gt0wga4j1#

在Azure中,订阅中没有这样的Azure资源Object Id,只有一个格式为/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}ResourceId
你可以通过你使用的Get-AzResource获取它,它返回ResourceId

nbysray5

nbysray52#

有点晚了,但你可以试试

$Id = (Get-AzResource -Name 'my-resource' -ResourceType {resource-type}).Identity.PrincipalId

链接:https://github.com/MicrosoftDocs/azure-docs/issues/44391

相关问题