Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or operable program

16,929

Solution 1

Please install the Pnp PowerShell assembly in your system from here:

SharePoint/PnP-PowerShell

And then consume in SharePoint Online Management Shell: Connect-PnPOnline –Url https://tenant.sharepoint.com –Credentials (Get-Credential)

It will pop up a credential window, input credential and then continue: enter image description here

Solution 2

If the machine has Internet access and you're on PowerShell 6 or later, it's actually easier to use PowerShell-Get by running:

Install-Module SharepointPNPPowershellOnline

Note: PowerShellGet is available for earlier PowerShell versions as well, but needs to be installed first - see here.

Share:
16,929
john Gu
Author by

john Gu

Updated on June 04, 2022

Comments

  • john Gu
    john Gu almost 2 years

    I have windows 7 64-bit , and i have install sharepoint management shell from this link https://www.microsoft.com/en-us/download/details.aspx?id=35588.

    but when i open the SP management shell and i try to run this command:-

    PS C:\> Connect-PnPOnline https://*****.sharepoint.com/sites/***/
    

    I got this error:-

    Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + Connect-PnPOnline + ~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Connect-PnPOnline:String) [], C ommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

    so not sure what i am missing?

    Here is my version table:-

    PS C:\> $psversiontable
    
    Name                           Value
    ----                           -----
    PSVersion                      3.0
    WSManStackVersion              3.0
    SerializationVersion           1.1.0.1
    CLRVersion                     4.0.30319.42000
    BuildVersion                   6.2.9200.22198
    PSCompatibleVersions           {1.0, 2.0, 3.0}
    PSRemotingProtocolVersion      2.2
    
    • jrider
      jrider about 6 years
      Have you ran the install-module ?
    • john Gu
      john Gu about 6 years
      @jrider trying to run this command will raise this error Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1
    • jrider
      jrider about 6 years
      After further reading of the documentation (initial comment) there is an alternate installation for lower versions of powershell. However, it does mention you major version ($PSVersionTable.PSVersion) should be above 3 (You might need to update). In short, it says you can run this to install the module: Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent‌​.com/sharepoint/PnP-‌​PowerShell/master/Sa‌​mples/Modules.Instal‌​l/Install-SharePoint‌​PnPPowerShell.ps1')
    • john Gu
      john Gu about 6 years
      @jrider this will try to install a software named package managemnt.. i am not sure if i should trust this
    • jrider
      jrider about 6 years
      This documentation is from Microsoft (I would trust it). If you don't feel comfortable with it. Your only other alternative is to update your PowerShell version.
    • john Gu
      john Gu about 6 years
      @jrider now i run the above script as you mentioned Invoke-Expression (New-Object Net.WebClient).DownloadString('https://raw.githubusercontent‌​.com/sharepoint/PnP-‌​PowerShell/master/Sa‌​mples/Modules.Instal‌​l/Install-SharePoint‌​PnPPowerShell.ps1') then i restarted my PC,, but when i try to run Install-Module SharePointPnPPowerShellOnline .. i got the following error Install-Module : The 'Install-Module' command was found in the module 'PowerShellGet', but the module could not be loaded. For more information, run 'Import-Module PowerShellGet'. At line:1 char:1
    • john Gu
      john Gu about 6 years
      . now i am running sharepoint online so is the script you mentioned targetting it ?
    • jrider
      jrider about 6 years
      Install-Module does not work in your version of powershell. Try running your Connect-PnpOnline again
    • john Gu
      john Gu about 6 years
      @jrider also $PSVersionTable is showing the same values .. should this got updated after the installation link you send?
    • john Gu
      john Gu about 6 years
      @jrider i am getting this now Connect-PnPOnline : The term 'Connect-PnPOnline' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    • jrider
      jrider about 6 years
      This did not update powershell. This is just a way to get the module installed (per the documentation). Check to see if you have the module installed by running Get-Module SharePointPnPPowerShell* -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
    • jrider
      jrider about 6 years
    • jrider
      jrider about 6 years
      I'm moving this to chat. It is getting rather extensive
  • TG2
    TG2 almost 5 years
    Seem to be seeing this type of problem: github.com/SharePoint/PnP-PowerShell/issues/1340 "Connect-PnPOnline : A parameter cannot be found that matches parameter name 'Scopes'"