Sunday, 11 April 2021

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

Why PnP PowerShell Module ?

PnP PowerShell internally uses the Client-Side Object model code for its operations hence we can reduce the number of lines in our scripts by utilizing its built-in cmdlets and reduce the complexity of scripting implementations.  

When you are trying to connect the SharePoint Online and don't have the PnP PowerShell module for SharePoint Online on the local machine, you will see 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.


So, to get rid of this error, you must install "SharePointPnPPowerShellOnline" module.

Install SharePoint Online PnP PowerShell Module:

Before you install the module, you need to download and install Windows Management Framework 5.1 from https://www.microsoft.com/en-us/download/details.aspx?id=54616 on your operating system Windows 7/8, Windows 2008 or in Windows 2012/R2 environments. Restart your machine to complete the installation and follow the below.

1. Open SharePoint Online Management Shell or Windows PowerShell as Administrator and Run:
Install-Module SharePointPnPPowerShellOnline

This command will install the recent version of the PnP PowerShell Module.

If you are not able to download the module due to the below error and If you want to install on a machine without an internet connection and make the cmdlets automatically available in PowerShell, then follow the below steps:

Go to the computer with which has internet connection and enter below command on Windows PowerShell:
Save-Module -Name SharePointPnPPowerShellOnline -Path [c:\foldertosavemoduleto]


In the path specified a folder will be created called SharePointPnPPowerShellOnline. Copy this folder and all its contents to the target computer.

If you want to have the module only available for a specific user, copy the folder and its contents to
c:\users\[username]\documents\windowspowershell\modules

Note: that you might have to create this folder structure

If you want the module to be available for all users, copy the folder and its contents to 
c:\program files\windowspowershell\modules

Once it is done check if SharePoint Online PnP PowerShell Module is Installed and then connect to site.