Forum Discussion

akkers's avatar
akkers
Copper Contributor
Jun 03, 2025

Cannot install PnP.Powershell

Something has changed recently I can no longer execute scripts that I had. So I decided to re-install various bits and pieces. 

When I come to install PnP.Powershell I get an error:

'WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.

 

 

4 Replies

  • jimvh's avatar
    jimvh
    Copper Contributor

    Hi akkers,

    The old API v2 URL is deprecated. Microsoft moved to https://www.powershellgallery.com/api/v3.

    You could try the following:

    Unregister the old PSGallery:
    Unregister-PSRepository -Name "PSGallery"

     

    Register the new one (v3):
    Register-PSRepository -Name "PSGallery" `
                          -SourceLocation "https://www.powershellgallery.com/api/v3" `
                          -InstallationPolicy Trusted

     

    Verify it's updated:
    Get-PSRepository

     

    Try installing the module again:
    Install-Module -Name PnP.PowerShell

     

    Also check the TLS. (Some systems may not default to TLS 1.2, which is required)
    Run below code before installing the module.
    This will only affect your current Powershell session, so it wont change it permanently.

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

  • jimvh's avatar
    jimvh
    Copper Contributor

    Hi akkers,

    The old API v2 URL is deprecated. Microsoft moved to https://www.powershellgallery.com/api/v3.

    You could try the following:

    Unregister the old PSGallery:
    Unregister-PSRepository -Name "PSGallery"

     

    Register the new one (v3):
    Register-PSRepository -Name "PSGallery" `
                          -SourceLocation "https://www.powershellgallery.com/api/v3" `
                          -InstallationPolicy Trusted

     

    Verify it's updated:
    Get-PSRepository

     

    Try installing the module again:
    Install-Module -Name PnP.PowerShell

     

    Also check the TLS. (Some systems may not default to TLS 1.2, which is required)
    Run below code before installing the module.
    This will only affect your current Powershell session, so it wont change it permanently.

    [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

      • Timo-HH's avatar
        Timo-HH
        Copper Contributor

        Did you find a solution? I seem to have the same issue.

        Interestingly, it works when I connect my laptop to a hotspot on my phone, rather than to my FTTH connection. So it seems to be network related (at least, in my case).

Resources