I am getting "PackageManagement\Install-Package : Access to the cloud file is denied" errors while installing Az module in power shell

Viewed 7182

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.

3 Answers

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

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).

Related