Welcome to deBUG.to Community where you can ask questions and receive answers from Microsoft MVPs and other experts in our community.
0 like 0 dislike
9.6k views
in PowerShell by 6 7 9

I got this error "PowerShell Gallery is currently unavailable.  Please try again later." when I tried to publish a new script to PowerShell Gallary using the below command line

Publish-Script -Path D:\publish\test.ps1 -Repository PSGallery -NuGetApiKey o
PS C:\Users\Administrator> Publish-Script -Path D:\publish\test.ps1 -Repository PSGallery -NuGetApiKey o
Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable.  Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:2605 char:9
+         Get-PSGalleryApiAvailability -Repository $Repository
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
    + FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability

Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable.  Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1305 char:9
+         Get-PSGalleryApiAvailability -Repository $Repository
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
    + FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability
PS C:\Users\Administrator>

PowerShell Gallery is currently unavailable Please try again later


1 Answer

1 like 0 dislike
by 96 167 336
selected by
 
Best answer

To solve "Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable. Please try again later.", you will need to upgrade or change the security protocol to TLS1.2 by doing the following:

Steps

  • Open Windows PowerShell As Administrator.
  • Run the below cmdlet to change the security protocol to TLS1.2

      [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
    
  • Now, run the below cmdlet to publish your PowerShell Script to PowerShell Gallery

      Publish-Script -Path D:\publish\test.ps1 -Repository PSGallery -NuGetApiKey o
    

See Also

by 6 7 9
0 0
Thanks Mohamed, I am still can't publish my script to PowerShell Gallery and I got another error Failed to publish script 'Test': 'nuget.exe failed to push Method not found! I don't know if it's related to this error or not, Any advice!
by 96 167 336
0 0
Actually, it's clear that the new error raised due to the previous error has been solved by the above-provided solution, so I would suggest adding a new related question with all details to can support you (To add a related question please, click on the link icon below my answer and please don't forget to mark the answer as accepted in case it helped you!)
by 6 7 9
0 0
You're right, I am gonna ask a new question and please help me to fix this issue!
by 6 7 9
0 0
by 96 167 336
0 0
Sure, I will!
If you don’t ask, the answer is always NO!
...