Hi anonymous user hope it is not too late. But I have been facing to this issue again. I fixed that issue by installing the RSAT modules for managing AD using powershell. Somehow it added the required components for installing other modules.
Cannot install powershell modules
Hi,
I am facing to this problem for a few days and already loosing my mind :D. I would really appreciate your help.
My problem is that I am not able to install modules to my powershell console.
Example: Install-module -Name AzureAD
PS C:\WINDOWS\system32> Install-module -Name AzureAD
PackageManagement\Install-PackageProvider : Unable to find repository with SourceLocation ''. Use Get-PSRepository to see all available repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:3138 char:21
+ ... $null = PackageManagement\Install-PackageProvider -Name $script:N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...PackageProvider:InstallPackageProvider) [Install-PackageProvider], Exception
+ FullyQualifiedErrorId : RegisterPackageSourceRequired,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackageProvider
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 sys
tem.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:3144 char:21
+ ... $null = PackageManagement\Import-PackageProvider -Name $script:Nu ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (NuGet:String) [Import-PackageProvider], Exception
+ FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.ImportPackageProvider
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\PSModule.psm1:3148 char:30
+ ... tProvider = PackageManagement\Get-PackageProvider -Name $script:NuGet ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvider], Exception
+ FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageProvider
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 AzureAD
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [Install-Module], InvalidOperationException
+ FullyQualifiedErrorId : CouldNotInstallNuGetProvider,Install-Module
I know that there is missing the NuGet provider. So I have tried to copy that from another computer AND?
PS C:\WINDOWS\system32> Install-Module -Name AzureAD
PackageManagement\Install-Package : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:9709 char:34
+ ... talledPackages = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
I am literary stuck at this point. Anybody who was facing to this problem or know how to fix it?
Thank you!
7 additional answers
Sort by: Most helpful
-
Andy David - MVP 149.1K Reputation points MVP
2020-10-21T16:33:29.73+00:00 What have you attempted so far? Kinda hard to help without knowing that :)
One thing, you want force tls 1.2
so run this and then see if it gets you any further.[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
-
AmanpreetSingh-MSFT 56,646 Reputation points
2020-10-21T17:58:40.287+00:00 @GilakOndrej-3552 · You can run save-module AzureAD -Path C:\temp on any working machine, copy the C:\temp\AzureAD folder to the non-working machine and run below command on the non-working machine to import the module:
Import-module C:\test\AzureAD
That way you can use the module without having to spend time on fixing the NuGet issue. -
Manu Philip 18,676 Reputation points MVP
2020-10-21T16:03:42.103+00:00 Try the following two lines first
$wc = New-Object System.Net.WebClient
$wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials -
Leo Visser 91 Reputation points MVP
2020-10-24T19:07:13.14+00:00 This might be due to the fact that TLS1.0 is no longer supported for psgallery.
You can read more here:
https://dev.to/darksmile92/powershell-disabled-support-for-tls-1-0-for-the-gallery-update-module-and-install-module-broken-1oiiYou probably want to use these commando's (you might need to install powershellget again after that)
[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted