質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
PowerShell

Windows PowerShellはコマンドラインインターフェースであり、システム管理を含むWindowsタスク自動化のためのスクリプト言語です。

Azure

Azureは、マイクロソフトのクラウド プラットフォームで、旧称は Windows Azureです。PaaSとIaaSを組み合わせることで、 コンピューティング・ストレージ・データ・ネットワーキング・アプリケーションなど多くの機能を持ちます。

Q&A

解決済

1回答

797閲覧

Azure PowershellのGet-AzureRmResourceの例が間違っていないか

usugita_san

総合スコア226

PowerShell

Windows PowerShellはコマンドラインインターフェースであり、システム管理を含むWindowsタスク自動化のためのスクリプト言語です。

Azure

Azureは、マイクロソフトのクラウド プラットフォームで、旧称は Windows Azureです。PaaSとIaaSを組み合わせることで、 コンピューティング・ストレージ・データ・ネットワーキング・アプリケーションなど多くの機能を持ちます。

0グッド

0クリップ

投稿2017/11/28 03:56

Azure Powershell で Get-AzureRmResource コマンドを実行していて気になった事があります。

Azure PowerShellのバージョンは以下の通りです。

PowerShell

1PS C:\Users\username> Get-Module | ft name,version 2 3Name Version 4---- ------- 5AzureRM.Compute 2.3.0 6AzureRM.Profile 2.3.0 7AzureRM.Resources 3.3.0 8Microsoft.PowerShell.Management 3.1.0.0 9Microsoft.PowerShell.Utility 3.1.0.0 10PackageManagement 1.0.0.1 11PowerShellGet 1.0.0.1 12PSReadline 1.2 13 14PS C:\Users\username>

以下のコマンドを実行して、コマンドの例を見ると、こういう風に書いてあります。

Powershell

1get-help Get-AzureRmResource -example

PowerShell

1 -------------------------- Example 2: Get resources by resource group -------------------------- 2 3 PS C:\>Get-AzureRmResource -ResourceGroupName ContosoRG01 4 5 Name : Default1 6 ResourceGroupName : ContosoLabsRG 7 ResourceType : Microsoft.Web/serverFarms 8 Location : northeurope 9 ParentResource : 10 11 12 Name : ContosoLabWeb 13 ResourceGroupName : ContosoLabsRG 14 ResourceType : Microsoft.Web/sites 15 Location : northeurope 16 ParentResource : 17 18 This commands gets all Azure resources in the ContosoRG01 resource group.

でも実際にこんな風にコマンドを打つと、エラーになります。

PowerShell

1PS C:\Users\username> Get-AzureRmResource -ResourceGroupName ContosoRG01 2Get-AzureRmResource : 指定された名前のパラメーターを使用してパラメーター セットを解決できません。 3発生場所 行:1 文字:2 4+ Get-AzureRmResource -ResourceGroupName ContosoRG01 5+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 6 + CategoryInfo : InvalidArgument: (:) [Get-AzureRmResource]、ParameterBindingException 7 + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.Ge 8 tAzureResourceCmdlet 9PS C:\Users\username>

こちらのサイトを見ると、リソースグループ名の他にリソース名やリソースIDを指定しています。確かにそれならリソースの情報を見る事が出来ます。
https://docs.microsoft.com/en-us/powershell/module/azurerm.resources/get-azurermresource?view=azurermps-5.0.0

これは、exampleが間違えていると考えてよいのでしょうか?
だとしたら、これはどちらに報告するべきなのでしょうか?

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

こんばんは。
Azure PowerShellは詳しくないのですが既知の不具合というか仕様変更の様です。

ResourceGroupNameだけを指定する場合はGet-AzureRmResourceではなくFind-AzureRmResourceを使う事が奨められています。

powershell

1Find-AzureRmResource -ResourceGroupName ContosoRG01

ちなみに、手元のCloud Shellの環境(AzureRM.Resourcesのバージョンは5.0.0)では、

powershell

1PS Azure:\> Get-Module AzureRM.Resources | select Version 2 3Version 4------- 55.0.0

powershell

1PS Azure:\> get-help Get-AzureRmResource -example 2 3NAME 4 Get-AzureRmResource 5 6SYNOPSIS 7 Gets resources. 8 9 10 Example 1: Get all the resources of a particular type 11 12 PS C:\>Get-AzureRmResource -ResourceGroupName ResourceGroup11 -ResourceType microsoft.web/sites 13 14 This command gets a resource of the type microsoft.web/sites under ResourceGroup11. 15 16 17 Example 2: Get a resource by name 18 19 PS C:\>Get-AzureRmResource -ResourceGroupName ResourceGroup11 -ResourceName ContosoWebsite 20 21 This command gets a resource named ContosoWebsite under ResourceGroup11. 22 23 24 Example 3: Show all the status of storage accounts in a Resource Group 25 26 PS C:\>Get-AzureRmResource -ResourceGroupName ResourceGroup11 -ResourceType Microsoft.ClassicStorage/storageAccounts -ExpandProperties 27 | 28 Select * -Expand Properties | 29 Sort Name | 30 Format-Table Name,Status*

となっておりExampleは修正されています。

Azure PowerShellはGitHubで管理されてますので、フィードバックはこちらにIssueを上げれば良いでしょう。

投稿2017/11/28 15:29

stknohg

総合スコア796

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

usugita_san

2017/12/06 06:36

Get-Module AzureRM.Resources を入力しても何も出ないので、どうもインストールが必要なようです。 そこからやってみます。 ありがとうございました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問