0

I am trying to install Az module on my windows server 2016 via PowerShell but it is giving me the error shown in the screenshot below.

It gives same error when tried on Windows 10 server as well.

If I try to install Azure RM command still the same error.

I have .Net Framework 4.8 present on Windows 2016 server and .Net 4.7 on Windows 10 server. The PS version is 5.1 on both the server.

I tried referring couple solutions mentioned on multiple sites but no one seems to work.

Can anyone please let me know what am I missing or how can I resolve this error?

enter image description here

SRP
  • 999
  • 4
  • 21
  • 39

1 Answers1

0

I used to get these errors a lot back in the day.

Try to run this:

Find-Module PowerShellGet  | Install-module

if not this should work:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted

Then you should be able to install the module.

ref: https://techcommunity.microsoft.com/t5/windows-powershell/trying-to-install-module-azuread-but-get-psrepository-quot/m-p/202819

Clint Oliveira
  • 647
  • 3
  • 8
  • @ Clint Oliveira, thanks for your response. I tried the First command shared by you on Win 2016 OS and it gave the same error then I tried 2nd command, that command didn't gave any error but after executing that command I tried to run "Install-Module -Name Az -AllowClobber -Force" and it failed with error "PackageManagement\Install-Package : The version '1.1.1' of the module 'Az.Advisor' being installed is not catalog signed. Ensure that the version '1.1.1' of the module 'Az.Advisor' has the catalog file" on Windows 10 none of the above command worked. – SRP Jan 19 '21 at 05:49
  • One update but when i tried executing the “Install-Module -Name AzureRM -AllowClobber -Force” it worked fine but failed when tried “Install-Module -Name Az -AllowClobber -Force” – SRP Jan 19 '21 at 06:09
  • You would need to install either Az or AzureRM. You can install the Az modules and then use Enable-AzureRmAlias, if you want to support your old scripts and functions. You need to remove the AzureRM module first and then install the Az module. Install Az and AzureRm: https://github.com/MicrosoftDocs/azure-docs/issues/30510 How to migrate from AzureRM to Az in Azure PowerShell: https://azure.microsoft.com/en-us/blog/how-to-migrate-from-azurerm-to-az-in-azure-powershell/ – Clint Oliveira Jan 19 '21 at 06:36
  • For now, I will continue to use AzureRm as I needed it only to start\stop azure VM's on Win 2016 server. On Windows 10 server, I tried the offline method where i installed the MSI Az-Cmdlets-5.4.0.33905-x64.exe file and downloaded all the Azmodule on my server. Now the Az commands wors on it but I am getting error for creating an Azureprofile.json file to save my credentials which I can import later. Anyways I have raised another query for it. – SRP Jan 19 '21 at 08:57