1
votes

Good day!

Trying to install azure AZ module on my windows 10 machine getting below error. any help and suggestions appreciate. thank you.

PS C:\WINDOWS\system32> Install-Module -Name Az -AllowClobber

NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\user\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): Yes WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''. WARNING: Unable to download the list of available providers. Check your internet connection. PackageManagement\Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7468 char:21 + ... $null = PackageManagement\Install-PackageProvider -Name $script:N ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-Pac kageProvider], Exception + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackagePro vider

PackageManagement\Import-PackageProvider : No match was found for the specified search criteria and provider name 'NuGet'. Try 'Get-PackageProvider -ListAvailable' to see if the provider exists on the system. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7474 char:21 + ... $null = PackageManagement\Import-PackageProvider -Name $script:Nu ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProv ider

WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''. WARNING: Unable to download the list of available providers. Check your internet connection. PackageManagement\Get-PackageProvider : Unable to find package provider 'NuGet'. It may not be imported yet. Try 'Get-PackageProvider -ListAvailable'. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:7478 char:30 + ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi der], Exception + FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka geProvider

Install-Module : NuGet provider is required to interact with NuGet-based repositories. Please ensure that '2.8.5.201' or newer version of NuGet provider is installed. At line:1 char:1 + Install-Module -Name Az -AllowClobber + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException + FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module

2

2 Answers

1
votes

@SumanthMarigowda-MSFT Thank you so much,finally able to install PowershellGet/Azure Powershell Module

[following https://docs.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-5.1.0 to install Azure Module on Powershell which needs Powershell Get which in turn needs NuGet]

PS C:\WINDOWS\system32> Install-Module -Name PowershellGet -Force

NuGet provider is required to continue PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\aditgarg\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now? [Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): N

Since it prompts to have NuGet installed,I cancel the above command and issue the command in above line:

PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''. WARNING: Unable to download the list of available providers. Check your internet connection. Install-PackageProvider : No match was found for the specified search criteria for the provider 'NuGet'. The package provider requires 'PackageManagement' and 'Provider' tags. Please check if the specified package has the tags. At line:1 char:1

  • Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
  •   + CategoryInfo          : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
      + FullyQualifiedErrorId : NoMatchFoundForProvider,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
    
    

Your above solution fixes the NuGet Installation issue:

PS C:\WINDOWS\system32> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

Finally installing NuGet

PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force

Name Version Source Summary


nuget 2.8.5.208 https://onege... NuGet provider for the OneGet meta-package manager

PS C:\WINDOWS\system32>

Finally installing PowershellGet

PS C:\WINDOWS\system32> Install-Module -Name PowerShellGet -Force
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32>
PS C:\WINDOWS\system32> Get-InstalledModule -Name PowerShellGet

Version    Name                                Repository              Description
-------    ----                                ----------                       -----------
2.2.5      PowerShellGet                       PSGallery             PowerShell module with commands for discovering, installing, updating and publishing the PowerShell artifacts like Mo...

And now we can install the Azure PowerShell Module

PS C:\WINDOWS\system32>

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
  'Az modules installed at the same time is not supported.')
} else {
Install-Module -Name Az -AllowClobber -Scope CurrentUser

}

PS C:\WINDOWS\system32> Get-InstalledModule -Name Az

Version    Name                                Repository            Description

5.1.0      Az                                  PSGallery             Microsoft Azure PowerShell - Cmdlets to manage resources in Azure. This module  is compatible with WindowsPowerShell a...

PS C:\WINDOWS\system32>


Adding my comments on issue encountered when trying to connect to Azure(login):

More issues:

PS C:\WINDOWS\system32> Connect-AzAccount

Do you want to run software from this untrusted publisher?
File C:\Users\aditgarg\Documents\WindowsPowerShell\Modules\Az.Accounts\2.2.1   \Accounts.format.ps1xml is published by CN=Microsoft Corporation, O=Microsoft   Corporation, L=Redmond,
S=Washington, C=US and is not trusted on your system. Only run scripts from    trusted publishers.
[V] Never run  [D] Do not run  [R] Run once  [A] Always run  [?] Help   (default is "D"): Y
[V] Never run  [D] Do not run  [R] Run once  [A] Always run  [?] Help  (default is "D"): A
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
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Connect-AzAccount:String) [],   CommandNotFoundException
+ FullyQualifiedErrorId : CouldNotAutoloadMatchingModule

--trying to import the found module as suggested above--

PS C:\WINDOWS\system32> Import-Module -Name Az
Import-Module : File C:\Users\aditgarg\Documents\WindowsPowerShell\Modules  \Az\5.1.0\Az.psm1 cannot be loaded because running scripts is disabled on this  system. For more information, see
about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ Import-Module -Name Az
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : SecurityError: (:) [Import-Module], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess,Microsoft.PowerShell.Commands.ImportModuleCommand
PS C:\WINDOWS\system32>

Solution: https://docs.microsoft.com/en-us/troubleshoot/azure/active-directory/cannot-run-scripts-powershell as the above error basically says running scripts is disabled on this system

ie

PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust.   Changing the execution policy might expose you to the security risks described  in the about_Execution_Policies
help topic at https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to    change the execution policy?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help  (default is "N"): Y

(press Y, A may pose security risk) And now Connect-AzAccount works to connect to Azure(login).

Set the execution policy to Restricted after execution of commands: Set-ExecutionPolicy restricted

0
votes

The error is caused by the way Windows PowerShell interacts with the NuGet infrastructure delivering both the NuGet Package Provider and the Windows PowerShell Module.

The entire infrastructure is secured with SSL/TLS. This prevents eavesdropping and meddle in the middle-type attacks, where a malicious person with inject rogue code into a plain-text communication stream.

Windows PowerShell does not communicate with the infrastructure using TLS 1.2, but with a less secure encryption protocol. As with many other infrastructure, the NuGet infrastructure has switched off less secure encryption protocols. The best current way on Windows Server 2016 to interact with the infrastructure is using TLS 1.2.

To run the below cmdlets [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

You may also refer to this link

Note: the command only affects the current session and does not persist.

You may also check what version of TLS for client is set on computer. Looks like TLS 1.0 for client is required. (ref: https://powershell.org/forums/topic/wmf-5-1-upgrade-broken-repositories/)

TLS security related (ref: https://rnelson0.com/2018/05/17/powershell-in-a-post-tls1-1-world/)