LoginSignup
7
8

More than 5 years have passed since last update.

Azure PowerShell Azモジュールインストール時のエラー対応

Posted at

Azure PowerShell Azモジュールインストール時にエラーになったので、解決法をメモしておきます。

以下は公式ページ
Azure PowerShell モジュールのインストールInstall the Azure PowerShell module

環境

  • Windows 10 Pro
  • PowerShell 5.1.17134.590

Proxy設定

  • PowerShellを管理者権限で起動します。

  • Proxy環境下の場合は、Proxy設定をしておきます。

$password = ConvertTo-SecureString "password" -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential "username", $password
[System.Net.WebRequest]::DefaultWebProxy.Credentials = $cred

インストール時にエラー

  • 公式ページに従って以下のインストールコマンドを実行します。
Install-Module -Name Az -AllowClobber
  • ここでエラー
PackageManagement\Install-Package : 指定された検索条件とパッケージ名 'Az' と一致するものが見つかりませんでした。登録さ
れている使用可能なすべてのパッケージ ソースを確認するには、Get-PSRepository を使用します。
発生場所 C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 文字:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
  • Get-PSRepository コマンドを実行したところ、PSGalleryリポジトリが存在しないことが原因みたい。
Get-PSRepository
警告: パッケージ ソースが見つかりません。

対応

  • デフォルトのPSGalleryリポジトリを登録します。
Register-PSRepository -Default
  • Get-PSRepository コマンドを実行し、PSGalleryリポジトリが登録されたことを確認します。
Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
  • Azモジュールをインストールします。
Install-Module -Name Az -AllowClobbe
7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8