Cannot install powershell modules

Ondrej 121 Reputation points


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  
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 '' 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.
617 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ondrej 121 Reputation points

    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. Andy David - MVP 138K Reputation points MVP

    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
    5 people found this answer helpful.

  2. AmanpreetSingh-MSFT 56,216 Reputation points

    @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.

    1 person found this answer helpful.

  3. Manu Philip 16,901 Reputation points MVP

    Try the following two lines first

    $wc = New-Object System.Net.WebClient
    $wc.Proxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

  4. Leo Visser 91 Reputation points MVP

    This might be due to the fact that TLS1.0 is no longer supported for psgallery.
    You can read more here:

    You 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