CloudOffice365

How to resolve the connect-pnponline error : The term ‘connect-pnponline’ is not recognized as the name of a cmdlet,

The term 'connect-pnponline' is not recognized as the name of a cmdlet,

Problem

The error message you received, stating that the term ‘connect-pnponline’ is not recognized as the name of a cmdlet, suggests that the PowerShell cmdlet ‘Connect-PnPOnline’ is not available in your current environment.

‘Connect-PnPOnline’ is a cmdlet provided by the SharePoint Patterns and Practices (PnP) PowerShell module, which allows you to connect to SharePoint Online and perform various administrative tasks.

Solution

To resolve this issue, you can follow these steps:

  1. Install the SharePoint Patterns and Practices (PnP) PowerShell module if you haven’t done so already. You can install it by running the following command in an elevated (run as administrator) PowerShell session:
    powershell
    Install-Module -Name Pnp.PowerShell -Force
  2. After the installation completes, import the module by running the following command:
    powershell
    Import-Module -Name Pnp.PowerShell -Force

At this point you should be able to connect by using the Connect-PnPOnline command, however, if you are still not able to connect then check the version of the PowerShell

PS C:\Users> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.3031
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3031
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Download the new PowerShell by using the following link

https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-windows?view=powershell-7.3%23installing-the-msi-package%3C/a

Installing the MSI package

To install PowerShell on Windows, use the following links to download the install package from GitHub.

Once downloaded, double-click the installer file and follow the prompts.

The installer creates a shortcut in the Windows Start Menu.

  • By default the package is installed to 
    $env:ProgramFiles\PowerShell\<version>
  • You can launch PowerShell via the Start Menu or 
    $env:ProgramFiles\PowerShell\<version>\pwsh.exe

Once installed you can see the following

PS C:\Program Files\PowerShell\7> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.5
PSEdition                      Core
GitCommitId                    7.3.5
OS                             Microsoft Windows 10.0.19044
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0


PS C:\Program Files\PowerShell\7>

You now will be able to connect and will need the URL and credentials

PS C:\Program Files\PowerShell\7> Install-Module -Name Pnp.powershell -force
PS C:\Program Files\PowerShell\7> Import-Module -Name Pnp.powershell -force
PS C:\Program Files\PowerShell\7> connect-pnponline

cmdlet Connect-PnPOnline at command pipeline position 1
Supply values for the following parameters:
Url:

 

 

 

 

 

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button