Connect-AzContainerRegistry command not working

Hi folks,
I can connect to my Azure account and my subscription using
Connect-AzAccount -Subscription and Set-AzContext -Subscription commands. I have created storage accounts, VMs etc. without a hitch using Powershell. However, when I am trying to use Connect-AzContainerRegistry, I am getting the error:

Connect-AzContainerRegistry : The 'Connect-AzContainerRegistry' command was found in the 
module 'Az.ContainerRegistry', but the module could not be loaded. For more information, run 
'Import-Module Az.ContainerRegistry'.
At line:6 char:1
+ Connect-AzContainerRegistry -Name containerregistrydemo160980
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Connect-AzContainerRegistry:String) [], Comma 
   ndNotFoundException
    + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

And when I try to import the module, I get:

Import-Module : Could not load file or assembly 'file:///C:\\\OneDrive\Documents\Wi
ndowsPowerShell\Modules\Az.ContainerRegistry\2.2.3\Microsoft.Azure.Management.ContainerRegist
ry.dll' or one of its dependencies. The cloud file provider is not running. (Exception from 
HRESULT: 0x8007016A)
At line:1 char:1
+ Import-Module Az.ContainerRegistry
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Import-Module], FileLoadException
    + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportM 
   oduleCommand

I am not an expert in Powershell. I am using Visual studio 2022, WSL 2. Please help.

A M ANISUL HUQ,
Welcome to the forum. :wave:t3:

When you crosspost the same question at the same time to different forums you should at least post links to the other forums along with your question to avoid people willing to help you potentially wasting their time.

Thanks

reddit.com - Connect-AzContainerRegistry command not working

1 Like

Hey sorry about that. The solution is by going to “C:.…\OneDrive\Documents\WindowsPowerShell\Modules” location > Selecting everything > set “always keep on this device”.