Cannot install powershell modules

OndrejG 126 Reputation points
2020-10-21T15:56:16.453+00:00

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!

Azure Cloud Services
Azure Cloud Services
An Azure platform as a service offer that is used to deploy web and cloud applications.
767 questions
0 comments No comments
{count} votes

Accepted answer
  1. OndrejG 126 Reputation points
    2020-12-04T09:16:08.367+00:00

    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.

    5 people found this answer helpful.
    0 comments No comments

7 additional answers

Sort by: Most helpful
  1. OndrejG 126 Reputation points
    2020-10-30T13:38:45.53+00:00

    I was really upset by this issue so I have reinstalled my PC :(. But it finally works!!! Anyway thank you for your advices

    0 comments No comments

  2. Jason Heeter 1 Reputation point
    2020-11-09T20:59:06.62+00:00

    @GilakOndrej-3552 If it's any consolation, I've been fighting the same thing for several months after a moving to an new laptop. I'm one step away from reloading, the only reason I haven't is it's a work machine and I'd have to take it in to reload.
    For my situation I got a new laptop and after removing the second HDD it all started falling apart. I'm not sure if that was the catalyst but I haven't been able to get the package provider or nuget acknowledged by any of the powershell on my machine, in VSC, ISE in 5.1 or 7.0
    It's a total bust, I'm going to schedule a reload too but thought you might like to know it's not just you and oddly coincidental.

    0 comments No comments

  3. Camilo Angel 1 Reputation point
    2020-12-03T15:29:25.52+00:00

    Hi to all, i am facing same error but with another module, this command always had worked for me so i decided to check what i did before get this error and the only thing what i did was installed framework 4.8, I think the framework do something wrong over powershell, if anyone can fix this error without reinstall the pc (because i can't do this), i really appreciate that, thanks for your help, cheers!.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.