如何使用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。
Get-AzureRmResource -ResourceName 'my-resource' | fl
Parameter set cannot be resolved using the specified named parameters
Get-AzResource -Name 'my-resource'
gt0wga4j1#
在Azure中,订阅中没有这样的Azure资源Object Id,只有一个格式为/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}的ResourceId。你可以通过你使用的Get-AzResource获取它,它返回ResourceId。
Object Id
/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
ResourceId
Get-AzResource
nbysray52#
有点晚了,但你可以试试
$Id = (Get-AzResource -Name 'my-resource' -ResourceType {resource-type}).Identity.PrincipalId
链接:https://github.com/MicrosoftDocs/azure-docs/issues/44391
2条答案
按热度按时间gt0wga4j1#
在Azure中,订阅中没有这样的Azure资源
Object Id
,只有一个格式为/subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}
的ResourceId
。你可以通过你使用的
Get-AzResource
获取它,它返回ResourceId
。nbysray52#
有点晚了,但你可以试试
链接:https://github.com/MicrosoftDocs/azure-docs/issues/44391