首页 > 解决方案 > 如何使用 PowerShell 获取 Azure 资源的对象 ID

问题描述

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

我尝试使用Get-AzureRmResource -ResourceName 'my-resource' | fl但失败并出现错误:Parameter set cannot be resolved using the specified named parameters

我也尝试过使用Get-AzResource -Name 'my-resource',但在它检索到的信息中,它不包括对象 ID。

标签: azurepowershell

解决方案


In Azure, there is no such Object Id for azure resources in the subscription, there is just a ResourceId with the format /subscriptions/{subscription-id}/resourceGroups/{resource-group-name}/{resource-provider-namespace}/{resource-type}/{resource-name}.

You can get it via Get-AzResource you used, it returns the ResourceId.

enter image description here


推荐阅读