Wednesday, February 24, 2021

Solution of Nuget Provider Issue with PowerShell and AWS Tools

 On a AWS EC2 Windows 2012 server, my goal was to write some data to S3 bucket. I was using a small Powershell Script to copy the file to the S3 bucket. For that I needed to Install AWS Tools for Powershell and I used following command at Powershell prompt running as administrator:

Windows PowerShell

Copyright (C) 2016 Microsoft Corporation. All rights reserved.


PS C:\Users\SRV> Install-Module -Scope CurrentUser -Name AWSPowerShell.NetCore -Force

and it failed with following error:

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\SRV\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"): y

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.

Solution:

The solution is to enable TLS 1.2 on this Windows host, which you can do by running Powershell in administrator mode:


Set-ItemProperty -Path 'HKLM:\SOFTWARE\Wow6432Node\Microsoft\.NetFramework\v4.0.30319' -Name 'SchUseStrongCrypto' -Value '1' -Type DWord


Close your Powershell window, and reopen as administrator and check if TLS protocol is present by typing following command on PS prompt:

[Net.ServicePointManager]::SecurityProtocol

If the above shows Tls12 in the output, then we are all good and now you should be able to install AWS Tools.

I hope that helps.




No comments: