Share via

Connect-AzContainerRegistry command not working

A M ANISUL HUQ 0 Reputation points
2025-03-28T07:11:08.6033333+00:00

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:\Users\15146\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. Please help.

Windows for business | Windows Server | User experience | PowerShell
0 comments No comments

1 answer

Sort by: Most helpful
  1. A M ANISUL HUQ 0 Reputation points
    2025-03-31T06:47:20.6833333+00:00

    My research has shown that this is a known problem with OneDrive. When the

    C:\.......\OneDrive\Documents\WindowsPowerShell\Modules\ folder is stored in OneDrive then you must make sure that all files in the Documents\PowerShell and Documents\WindowsPowerShell folders are marked as Always keep on this device. Doing so has resulted in the removal of the error.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.