Unable to install Az powershell module with PS7 on windows10

Viewed 4433

I am administrator on my Windows10, and trying to install Azure PS module as per the documentation in here.

PS C:\Program Files\PowerShell\7> Install-Module -Name Az -Scope CurrentUser -Force -Allowclobber

However, I get the error message as below.. Install-Package: C:\program files\powershell\7\Modules\PowerShellGet\PSModule.psm1:9711 Line 9711 talledPackages = PackageManagement\Install-Package @PSBoundParameters Administrator rights are required to install or update. Log on to the computer with an account that has Administrator rights, and then try again, or install by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated rights (Run as Administrator).

It does not make sense why it throws this error even though I am already in admin privilege mode. Few other SO answers asked to set to use TLS 1.2, I have done that as well. Like so [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12.

What else could be the issue ?

1 Answers

Trying to install az module over existing modules will give this error and it appears to be the cause for this issue.

The way to solve this issue is by deleting already existing not in use previous az modules which you can find in the following path -

C:\Program Files\WindowsPowerShell\Modules.

Then run the following command -

Install-Module -Name Az -Scope CurrentUser -Repository PSGallery -Force -AllowClobber.

And this will solve your problem.

Also look at az module falsely throws Admin rights required error.

You can also check this discussion and find the similar answer in this comment.

Related