Get-AzResource
構文
ByTagNameValueParameterSet (既定)
Get-AzResource
[-Name <String>]
[-ResourceType <String>]
[-ODataQuery <String>]
[-ResourceGroupName <String>]
[-TagName <String>]
[-TagValue <String>]
[-ExpandProperties]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ByResourceId
Get-AzResource
-ResourceId <String>
[-ODataQuery <String>]
[-ExpandProperties]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
ByTagObjectParameterSet
Get-AzResource
-Tag <Hashtable>
[-Name <String>]
[-ResourceType <String>]
[-ODataQuery <String>]
[-ResourceGroupName <String>]
[-ExpandProperties]
[-ApiVersion <String>]
[-Pre]
[-DefaultProfile <IAzureContextContainer>]
[<CommonParameters>]
説明
Get-AzResource コマンドレットは、Azure リソースを取得します。
例
例 1: 現在のサブスクリプション内のすべてのリソースを取得する
Get-AzResource | Format-Table
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
testVM testRG Microsoft.Compute/virtualMachines westus
disk testRG Microsoft.Compute/disks westus
nic testRG Microsoft.Network/networkInterfaces westus
nsg testRG Microsoft.Network/networkSecurityGroups westus
ip testRG Microsoft.Network/publicIPAddresses westus
vnet testRG Microsoft.Network/virtualNetworks westus
testKV otherRG Microsoft.KeyVault/vaults eastus
storage otherResourceGroup Microsoft.Storage/storageAccounts eastus
testVM2 otherResourceGroup Microsoft.Compute/virtualMachines eastus
このコマンドは、現在のサブスクリプション内のすべてのリソースを取得します。
例 2: リソース グループ内のすべてのリソースを取得する
Get-AzResource -ResourceGroupName testRG | Format-Table
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
testVM testRG Microsoft.Compute/virtualMachines westus
disk testRG Microsoft.Compute/disks westus
nic testRG Microsoft.Network/networkInterfaces westus
nsg testRG Microsoft.Network/networkSecurityGroups westus
ip testRG Microsoft.Network/publicIPAddresses westus
vnet testRG Microsoft.Network/virtualNetworks westus
このコマンドは、リソース グループ "testRG" 内のすべてのリソースを取得します。
例 3: 指定されたワイルドカードと一致するリソース グループを持つすべてのリソースを取得する
Get-AzResource -ResourceGroupName other* | Format-Table
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
testKV otherRG Microsoft.KeyVault/vaults eastus
storage otherResourceGroup Microsoft.Storage/storageAccounts eastus
testVM2 otherResourceGroup Microsoft.Compute/virtualMachines eastus
このコマンドは、そのリソース グループが属するすべてのリソースを "other" と共に取得します。
例 4: 特定の名前を持つすべてのリソースを取得する
Get-AzResource -Name testVM | Format-List
Name : testVM
ResourceGroupName : testRG
ResourceType : Microsoft.Compute/virtualMachines
Location : westus
ResourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM
Tags :
Name Value
====== ========
Dept IT
Year 2002
Status Approved
このコマンドは、リソース名が "testVM" であるすべてのリソースを取得します。
例 5: 指定されたワイルドカードと一致する名前を持つすべてのリソースを取得する
Get-AzResource -Name test* | Format-Table
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
testVM testRG Microsoft.Compute/virtualMachines westus
testKV otherRG Microsoft.KeyVault/vaults eastus
testVM2 otherResourceGroup Microsoft.Compute/virtualMachines eastus
このコマンドは、リソース名が "test" で始まるすべてのリソースを取得します。
例 6: 特定のリソースの種類のすべてのリソースを取得する
Get-AzResource -ResourceType Microsoft.Compute/virtualMachines | Format-Table
Name ResourceGroupName ResourceType Location
---- ----------------- ------------ --------
testVM testRG Microsoft.Compute/virtualMachines westus
testVM2 otherResourceGroup Microsoft.Compute/virtualMachines eastus
このコマンドは、仮想マシンである現在のサブスクリプション内のすべてのリソースを取得します。
例 7: リソース ID でリソースを取得する
Get-AzResource -ResourceId /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM
Name : testVM
ResourceGroupName : testRG
ResourceType : Microsoft.Compute/virtualMachines
Location : westus
ResourceId : /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/testRG/providers/Microsoft.Compute/virtualMachines/testVM
Tags :
Name Value
====== ========
Dept IT
Year 2002
Status Approved
このコマンドは、指定されたリソース ID を持つリソースを取得します。これは、リソース グループ "testRG" の "testVM" という仮想マシンです。
例 8: 展開されたプロパティを持つリソースを取得する
Get-AzResource -Name testVM -ResourceGroupName testRG -ExpandProperties
このコマンドは、リソース グループ "testRG" の "testVM" という名前のリソースを取得し、プロパティを展開して、CreatedTime、ChangedTime、その他のリソース メタデータなどの追加の詳細を含めます。
パラメーター
-ApiVersion
Get-AzResource コマンドレットは、Azure リソースを取得します。
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: False
DontShow: False
パラメーター セット
(All)
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-DefaultProfile
Azure との通信に使用される資格情報、アカウント、テナント、サブスクリプション
パラメーターのプロパティ
型: IAzureContextContainer
規定値: None
ワイルドカードのサポート: False
DontShow: False
Aliases: AzContext, AzureRmContext, AzureCredential
パラメーター セット
(All)
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-ExpandProperties
指定すると、リソースのプロパティが展開されます。
パラメーターのプロパティ
パラメーター セット
(All)
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-Name
取得するリソースの名前。 このパラメーターは、文字列の先頭または末尾でワイルドカードをサポートします。
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: True
DontShow: False
Aliases: リソース名
パラメーター セット
ByTagNameValueParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
ByTagObjectParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-ODataQuery
Get-AzResource コマンドレットは、Azure リソースを取得します。
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: False
DontShow: False
パラメーター セット
(All)
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-Pre
Get-AzResource コマンドレットは、Azure リソースを取得します。
パラメーターのプロパティ
パラメーター セット
(All)
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-ResourceGroupName
取得されるリソースが属するリソース グループ。 このパラメーターは、文字列の先頭または末尾でワイルドカードをサポートします。
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: True
DontShow: False
パラメーター セット
ByTagNameValueParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
ByTagObjectParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-ResourceId
次の例のように、完全修飾リソース ID を指定 /subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/providers/Microsoft.Compute/virtualMachines
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: False
DontShow: False
Aliases: ID (アイディー)
パラメーター セット
ByResourceId
配置: Named
必須: True
パイプラインからの値: False
プロパティ名別のパイプラインからの値: True
残りの引数からの値: False
-ResourceType
取得するリソースのリソースの種類。 たとえば、Microsoft.Compute/virtualMachines
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: False
DontShow: False
パラメーター セット
ByTagNameValueParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
ByTagObjectParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-Tag
指定した Azure タグを持つリソースを取得します。 Name キーまたは Name キーと Value キーを持つハッシュ テーブルを入力します。 ワイルドカード文字はサポートされていません。"タグ" は、リソースとリソース グループに適用できる名前と値のペアです。 タグを使用して、部門やコスト センターなどのリソースを分類したり、リソースに関するメモやコメントを追跡したりできます。 リソースにタグを追加するには、New-AzResource または Set-AzResource コマンドレットの Tag パラメーターを使用します。 定義済みのタグを作成するには、New-AzTag コマンドレットを使用します。 Windows PowerShell のハッシュ テーブルのヘルプについては、'Get-Help about_Hashtables' を実行してください。
パラメーターのプロパティ
型: Hashtable
規定値: None
ワイルドカードのサポート: False
DontShow: False
パラメーター セット
ByTagObjectParameterSet
配置: Named
必須: True
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-TagName
取得するリソースのタグ内のキー。
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: False
DontShow: False
パラメーター セット
ByTagNameValueParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
-TagValue
取得するリソースのタグ内の値。
パラメーターのプロパティ
型: String
規定値: None
ワイルドカードのサポート: False
DontShow: False
パラメーター セット
ByTagNameValueParameterSet
配置: Named
必須: False
パイプラインからの値: False
プロパティ名別のパイプラインからの値: False
残りの引数からの値: False
CommonParameters
このコマンドレットでは、一般的なパラメーター -Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction、-WarningVariable の各パラメーターがサポートされています。 詳細については、about_CommonParameters を参照してください。
出力