Error trying to install Packages or Modules from PowershellGallery

Welcome Forums General PowerShell Q&A Error trying to install Packages or Modules from PowershellGallery

Viewing 9 reply threads
  • Author
    Posts
    • #215127
      Participant
      Topics: 1
      Replies: 3
      Points: 21
      Rank: Member

      Hi everyone.

      Been trying to bypass an error when trying to install AzureAD, AzureADPreview or even PowerShellGet from powershell.

      I keep getting an error saying:

      PackageManagement\Install-Package : Package ‘PackageManagement’ failed to download.
      At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21

      PackageManagement\Install-Package : Package ‘AzureAD’ failed to download.
      At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
      + … $null = PackageManagement\Install-Package @PSBoundParameters
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ResourceUnavailable: (C:\Users\nb1573…D\AzureAD.nupkg:String) [Install-Package], Excep
      tion
      + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
      kage

      PackageManagement\Install-Package : Package ‘AzureADPreview’ failed to download.
      At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
      + … $null = PackageManagement\Install-Package @PSBoundParameters
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ResourceUnavailable: (C:\Users\nb1573…ADPreview.nupkg:String) [Install-Package], Excep
      tion
      + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
      kage

       

      I tried the proxy credential setting (https://blogs.technet.microsoft.com/keithmayer/2016/01/06/quick-tip-using-azure-powershell-with-web-proxy-and-fiddler/) but I’m not behind a proxy. I tried to update PowerShellGet unsucessfully. I even tried download nupkg manually and then install it, also unsucessfull:

      PS C:\WINDOWS\system32> Install-Module “D:\user\Downloads\azuread.2.0.2.76.nupkg”
      PackageManagement\Install-Package : No match was found for the specified search criteria and module name
      ‘D:\user\Downloads\azuread.2.0.2.76.nupkg’. 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], Ex
      ception
      + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

      Does any of you have any hint on what problem I might be getting?

      Thanks in advance,

      David

    • #215715
      Participant
      Topics: 1
      Replies: 3
      Points: 21
      Rank: Member

      Oh, and always in powershell running as Administrator.

      Any suggestion or idea?

      Thanks in advance,

      David

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

      Hi David,

      Does the machine not have internet access? If it does, why not use

      
      Install-Module -Name AzureAD
      
      

      Check out this link – https://www.powershellgallery.com/packages/AzureAD/2.0.2.76

      I’ve seen cases where the PSGallery wasn’t registered, so if the command fails even with internet access, try

      
      Install-Module -Name AzureAD -Repository PSGallery
      
      

      If this works, you’ll need to re-register the gallery repository so you don’t have to type -Repository PSGallery every time you want to install something.

      In that case, see this link for some great tips – https://gist.github.com/guitarrapc/79d31b8cd02649075642b77c4ae796ab

      I hope this helps!

    • #216222
      Participant
      Topics: 1
      Replies: 3
      Points: 21
      Rank: Member

      Hi Doug. Thank you for your time and your response.

      I’ve tried both of the Install-Module commands and still unable to install.

      But I’ve dig dipper about the internet connection issue you were talking about (yes, the computer has internet) but I’m unable to reach http://www.powershellgallery.com via ping command in powershell.

      Any idea why?

      Thanks in advance,

      David

      <hr />

      PS D:\Projects\MicrosoftSamples\azure-iot-connected-factory> Install-Module -Name AzureAD

      Untrusted repository
      You are installing the modules from an untrusted repository. If you trust this repository, change its
      InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
      ‘PSGallery’?
      [Y] Yes [A] Yes to All [N] No [L] No to All Suspend [?] Help (default is “N”): y
      WARNING: Source Location ‘https://www.powershellgallery.com/api/v2/package/AzureAD/2.0.2.76&#8217; is not valid.
      PackageManagement\Install-Package : Package ‘AzureAD’ failed to download.
      At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
      + … $null = PackageManagement\Install-Package @PSBoundParameters
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ResourceUnavailable: (C:\Users\nb1573…D\AzureAD.nupkg:String) [Install-Package], Excep
      tion
      + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
      kage

      PS D:\Projects\MicrosoftSamples\azure-iot-connected-factory> Install-Module -Name AzureAD -Repository PSGallery

      Untrusted repository
      You are installing the modules from an untrusted repository. If you trust this repository, change its
      InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from
      ‘PSGallery’?
      [Y] Yes [A] Yes to All [N] No [L] No to All Suspend [?] Help (default is “N”): y
      WARNING: Source Location ‘https://www.powershellgallery.com/api/v2/package/AzureAD/2.0.2.76&#8217; is not valid.
      PackageManagement\Install-Package : Package ‘AzureAD’ failed to download.
      At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
      + … $null = PackageManagement\Install-Package @PSBoundParameters
      + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo : ResourceUnavailable: (C:\Users\nb1573…D\AzureAD.nupkg:String) [Install-Package], Excep
      tion
      + FullyQualifiedErrorId : PackageFailedInstallOrDownload,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPac
      kage

      PS D:\Projects\MicrosoftSamples\azure-iot-connected-factory> ping http://www.powershellgallery.com

      Pinging psg-prod-centralus.cloudapp.net [168.61.186.235] with 32 bytes of data:
      Request timed out.
      Request timed out.
      Request timed out.
      Request timed out.

      Ping statistics for 168.61.186.235:
      Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
      PS D:\Projects\MicrosoftSamples\azure-iot-connected-factory> ping http://www.google.com

      Pinging http://www.google.com [172.217.16.228] with 32 bytes of data:
      Reply from 172.217.16.228: bytes=32 time=18ms TTL=55
      Reply from 172.217.16.228: bytes=32 time=17ms TTL=55
      Reply from 172.217.16.228: bytes=32 time=18ms TTL=55
      Reply from 172.217.16.228: bytes=32 time=19ms TTL=55

      Ping statistics for 172.217.16.228:
      Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
      Approximate round trip times in milli-seconds:
      Minimum = 17ms, Maximum = 19ms, Average = 18ms

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

      I would assume there is some sort of proxy/content inspection at your perimeter firewall that is stomping on these attempts. Are you able to test over a hotspot or VPN?

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

      It was related to security if it’s this. Have you found and tried this?

      Work Around

      In your PowerShell session run:
      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
      Note: This will not permanently update your TLS but will allow you to interact with the PowerShell Gallery during this session.

       

      PowerShell Gallery TLS Support

      • This reply was modified 1 month, 2 weeks ago by Doug Maurer.
    • #218823
      Participant
      Topics: 1
      Replies: 3
      Points: 21
      Rank: Member

      Hi Doug. Thank you, it worked like a charm!

      I’ve tryied over a VPN and it didn’t work, sorry for haven’t provided any feedback, but tried the suggested work around and it worked!

      Thank you very much,

      David

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

      Great! I saw it on Reddit and I thought it might be related. I just had to find this post. Thank you for following up.

    • #223032
      Participant
      Topics: 7
      Replies: 22
      Points: 39
      Rank: Member

      Hey Doug Maurer, thank you so much for posting this. I tried various other means using the -proxy parameter etc., but nothing worked. Your solution worked like a charm sir. Thanks so much!

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

      Awesome!

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