I am trying to install Az module on windows power shell by "Install-Module -Name Az -Scope CurrentUser -Force -Allowclobber command". But i am getting below error.

PS C:\WINDOWS\system32> Install-Module -Name Az -Scope CurrentUser -Force -Allowclobber
PackageManagement\Install-Package : Access to the cloud file is denied
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:9711 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : System.ComponentModel.Win32Exception,Microsoft.PowerShell.Commands.RemoveItemCommand,Microsoft.PowerShell.PackageManagement.Cmdlets.Instal 
   lPackage

I searched and found some issue is with onedrive sync activated in my system. Can you please help me on this to install Az module in powershell.

4

There are 4 answers

0
melkorCba On

I think the reason is PowerShell Gallery is blocked by the firewall. Anyway, try installing it using MSI. It worked for me.

0
Mohit Kumar Sharma On

I tried to install the latest release of the Az module and it worked Az 6.0.0.

Used the below link for reference.

https://github.com/Azure/azure-powershell/releases

0
Zarak1 On

See if/where you have Az module installed already using this command

Get-Module -ListAvailable

I found az installed in onedrive/documents/WindowsPowershell, and removed it by deleting the package manually.

Once deleted, I tried the install command again. That helped me.

To your question, I guess you'll have to check the PATH variable I guess, for you to avoid packages being installed in OneDrive(Happens probably when you run powershell with normal user rather than when run as admin).

0
Ol'seun Iyadi On

This is a security measure that decides which scripts can be run. The execution policy has four main configurations:

Restricted This configuration, which is the default, doesn’t allow you to run scripts.

AllSigned This configuration allows you to run only scripts that have been cryptographically signed by a trusted party

RemoteSigned This configuration allows you to run any script you write, and any script you download as long as it’s been cryptographically signed by a trusted party.

Unrestricted This configuration allows you to run any scripts.

Solution:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force

NOTE:

The solution above was dependent for my use case, yours may slightly be different from mine so apply extreme caution before using the solution provided.