AzureRMモジュールをアンインストールする方法

Azure AzurePowershell
この記事は約4分で読めます。

現在ではAZ Powershellモジュールが最新のAzureを操作するPowershellモジュールですが、少し古いモジュールであるAzureRMモジュールをアンインストールする方法をまとめました。

広告

アンインストール方法

「AzureRM」をアンインストールするために一度「Azモジュール」をインストールし、Azモジュールの中に含まれるコマンドを利用して「AzureRM」のアンインストールを行います。

「Azモジュール」をインストール

Install-Module -Name Az -AllowClobber -Scope CurrentUser
「Azモジュール」をインストールしている画面

Azモジュールのコマンドを利用して「AzureRM」をアンインストール

Uninstall-AzureRm
「AzureRM」をアンインストールしている画面

「WARNIG」と出ますが、問題ありません。

Uninstall-AzureRm 実行時にエラーが出た場合

以下のようなエラーが出た場合には、powhershellのインターフェースをすべて閉じて新しいセッションを起動して試してみてください。

今起動しているセッションではモジュールが競合を起こしてコマンド実行できない可能性があります。

PS C:\>Uninstall-AzureRm
警告: AzureRM.Profile already loaded. Az and AzureRM modules cannot be imported in the same session or used in the same
 script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm'
cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of
your runbooks import both Az and AzureRM modules. More information can be found here:

魅力的な古代の水槽
シヴァモッガは、インドのカルナータカ州に位置する都市で、古代インドの叙事詩「ラーマーヤナ」や「マハー
警告: AzureRM.Profile already loaded. Az and AzureRM modules cannot be imported in the same session or used in the same script or runbook. If you are running PowerShell in an environment you control you can use the 'Uninstall-AzureRm' cmdlet to remove all AzureRm modules from your machine. If you are running in Azure Automation, take care that none of your runbooks import both Az and AzureRM modules. More information can be found here:
魅力的な古代の水槽
シヴァモッガは、インドのカルナータカ州に位置する都市で、古代インドの叙事詩「ラーマーヤナ」や「マハー
Uninstall-AzureRm : 'Uninstall-AzureRm' コマンドはモジュール 'Az.Accounts' で見つかりましたが、このモジュールを読み込む ことができませんでした。詳細については、'Import-Module Az.Accounts' を実行してください。 発生場所 行:2 文字:1 + Uninstall-AzureRm + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Uninstall-AzureRm:String) [], CommandNotFoundException + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule PS C:\>

アンインストールの確認

[get-command]を利用して、「AzureRM」がアンインストールされたことを確認できます。

get-command |select-string "get-AzureRMvm"
「AzureRM」がアンインストールされたことを確認している画面

何もコマンドが出てこなければアンインストールできています。

【参考】AZコマンドでログイン確認

AzureRMのアンインストールが完了したら、AZコマンドでAzureにログインできるようになっているので、必要であればログイン確認してみてください。

Connect-AzAccount
「Connect-AzAccount」の実行画面

エラーなどが出力されず、サブスクリプション名やテナントidなどが出力されればログイン完了です。

タイトルとURLをコピーしました