Why can't PowerShell load file or assembly to run Azure PowerShell Module?

1

I can't get PowerShell to run connect-azaccount. When I invoke it (using connect-azaccount -subscriptionid #######...) I get:

connect-azaccount : The 'connect-azaccount' command was found in the module 'Az.Accounts', but the module could not be loaded. For more information, run 'Import-Module Az.Accounts'. At line:1 char:1 + connect-azaccount -subscriptionid ######### ... + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (connect-azaccount:String) [], CommandNotFoundException + FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

Per this troubleshooting module, the issue could be outdated .NET. But I updated to the latest version and that didn't resolve the problem. Same results.

When I run Import-Module Az.Accounts I get:

Import-Module : Could not load file or assembly 'file://\\internal_corp_domain.com\Profiles\my_username\My Documents\WindowsPowerShell\Modules\Az.Accounts\1.8.0\Microsoft.Azure.PowerShell.Authentication.Abstractions.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) At line:1 char:1 + Import-Module Az.Accounts + ~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Import-Module], FileLoadException + FullyQualifiedErrorId : FormatXmlUpdateException,Microsoft.PowerShell.Commands.ImportModuleCommand

The file path in that last error is puzzling. It appears to maybe be a network share. There are many discussions about this online, but nothing appears pertinent except that I might have a blocked file related to NTFS. Searches for NTFS tell me what it is, but I don't see how to find a block, espec when the path is to a network share I can't access.
Any pointers?

azure
powershell
azure-powershell
asked on Stack Overflow May 20, 2020 by mike_butak

1 Answer

0

Upgrading from PowerShell 5.1 to PowerShell 7 solved the issue.

answered on Stack Overflow May 21, 2020 by mike_butak

User contributions licensed under CC BY-SA 3.0