not able to install modules

Welcome Forums General PowerShell Q&A not able to install modules

Viewing 6 reply threads
  • Author
    Posts
    • #227800
      Participant
      Topics: 30
      Replies: 74
      Points: 400
      Rank: Contributor

      Hi,
      when I use powershell 5.1 to install the azureAD module I get the following error

      WARNING: Unable to resolve package source ‘https://www.powershellgallery.com/api/v2′. PackageManagement\Install-Package : No match was found for the specified search criteria and module name ‘msonline’. Try Get-PSRepository to see all available registered module repositories. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21 + …          $null = PackageManagement\Install-Package @PSBoundParameters +                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo          : ObjectNotFound: (Microsoft.Power….InstallPackage:InstallPackage) [Install-Package], Exception + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
      when running powershell 6 I’m able to install AzureAD but when I check get-module  the AzureAD module is not listed
      when I run get-installedModule -Name AzureAD -Allversions I get this as feedback

      Version              Name                                Repository           Description ——-              —-                                ———-           ———– 2.0.2.76             AzureAD                             PSGallery            Azure Active Directory V2 General Availability Module….

      but when I run connect-azureAD (which would normally pops up the authentication windows to enter username password and mfa) this is not happening
      do you have any ideas on how to troubleshoot this?

      Paul

    • #227842
      Participant
      Topics: 3
      Replies: 340
      Points: 1,120
      Helping Hand
      Rank: Community Hero

      Try this, run this in 5.1 and then try to install the module.

      [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
      
    • #227875
      Participant
      Topics: 30
      Replies: 74
      Points: 400
      Rank: Contributor

      Doug you rock thanks for this

      can you explain to me what this does exactly

      Best regards

      Paul

      • This reply was modified 2 weeks, 5 days ago by acer460527.
    • #227887
      Participant
      Topics: 3
      Replies: 340
      Points: 1,120
      Helping Hand
      Rank: Community Hero

      They dropped support for TLS 1.0, so you instructed powershell to use 1.2. See this thread.
      Glad I could help.

    • #228067
      Participant
      Topics: 30
      Replies: 74
      Points: 400
      Rank: Contributor

      another question
      I’m preparing a script that is going to be shared with a couple of users.
      and they need to have to install the required modules as well.
      is there a way to test what the current security protocol state is?
      this way I can integrate this in my checks that if current security protocol is not equal to
      [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
      to run this?

    • #228079
      Participant
      Topics: 3
      Replies: 340
      Points: 1,120
      Helping Hand
      Rank: Community Hero

      It’s only an issue in 5.1. What’s the harm in adding this to the beginning of each of your scripts just in case? Even if it’s set, it won’t error. However, you could potentially check it like this, but surely there is a better way.

      if([Net.ServicePointManager]::SecurityProtocol -notmatch 'tls12')
      {
          [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
      }
      

      Or

      if(([Net.ServicePointManager]::SecurityProtocol -split ',').trim() -notcontains 'tls12')
      {
          [Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
      }
      
    • #228088
      Participant
      Topics: 30
      Replies: 74
      Points: 400
      Rank: Contributor

      thanks Doug,
      the goal is to create a check.ps where all these things are checked and once a module is installed I don’t require to change the current settings

       

      Paul

       

Viewing 6 reply threads
  • You must be logged in to reply to this topic.