Mustafa Elimam
Mustafa Elimam

Reputation: 41

Can't install Azure Module in PowerShell

When installing the Azure module:

PS> Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force

I get this error:

PackageManagement\Install-Package : Could not find a part of the path 'C:\Users\MB\Documents\WindowsPowerShell\Modules\Az.Accounts\1.7.1'. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21

Upvotes: 4

Views: 7796

Answers (2)

Brain2000
Brain2000

Reputation: 4894

According to Microsoft, you can also install the MSI directly since their Powershell module installer is broken at the moment.

According to the documentation:
(https://learn.microsoft.com/en-us/powershell/azure/install-az-ps-msi)

Navigate to the Azure Github release page https://github.com/Azure/azure-powershell/releases
Scroll down until you find the latest Assets chevron that contains an Az-Cmdlets-x.x.x-x64.msi file.
Download and install the MSI.
Relaunch Powershell and you should be good to go.

Upvotes: 2

Scepticalist
Scepticalist

Reputation: 3923

Your best option here is to start from scratch:

  1. Go to 'C:\Users\MB\Documents\WindowsPowerShell\Modules\' and remove all folders starting with "Az"
  2. Launch PS as admin and update NuGet to latest version:

    Install-PackageProvider -Name NuGet -Force -Scope AllUsers
    
  3. In the same window install latest version of PackageProvider:

    Install-Module -Name PackageManagement -Scope AllUsers -Force -AllowClobber
    
  4. In the same window install latest version of PowerShellGet

    Install-Module -Name PowerShellGet -Scope AllUsers -Force -AllowClobber
    
  5. Install Azure

    Install-Module -Name Az -Scope CurrentUser -Force -Allowclobber
    

Upvotes: 0

Related Questions