



SharePoint Patterns and Practices (PnP) contains a library of PowerShell commands (PnP PowerShell) that allows you to perform complex provisioning and artifact management actions towards SharePoint.
What is PnP?
Patterns and Practices where Microsoft and external members contribute to the implementation practices for SharePoint. PnP libraries are created to serve the needs of developers for easy learning and implementation of logic through client-side programming.
Why we need PnP PowerShell?
PnP PowerShell internally implements Client-Side Object model for its operations. This, in turn, makes the operations adaptable. The same set of operations can be executed on any SharePoint environment. Using PnP PowerShell, the single line of code is used to access any object on SharePoint, where in with traditional client side or server-side object model, multiple lines of code are required to access the objects. The code complexity reduces through this implementation.
Requirements
Windows 10 , or if you have PowerShellGet installed
There are 3 ways to install the cmdlets.
1.Install them from the PowerShell Gallery .
2.Download the setup files
3.Run a PowerShell script to download the PowerShellGet module and install the cmdlets subsequently.
Note - the Preferred way is to Install them from the PowerShell GalleryCommand to Install
Run the following commands to install the desired PowerShell cmdlets:
Install-Module SharePointPnPPowerShellOnline
Install-Module SharePointPnPPowerShell2019
Install-Module SharePointPnPPowerShell2016
Install-Module SharePointPnPPowerShell2013
Install SharePoint Online PnP Cmdlets
Now let’s attempt to install and play a little with the SharePoint Online PnP Module
1.At the command line enter the following and press enter:
Install-Module SharePointPnPPowerShellOnline2.Type “ A ” and press enter
And there you go, easy as that the SharePoint Online PnP Modules is now installed. Next let’s check what version and maybe look around a little 😊
Check Version Installed
Next let’s check the version of SharePoint Online Pnp PowerShell installed
3.Type the following and press enter:
Get-InstalledModule -Name SharePointPnPPowerShellOnline | select Name,Version
Parameters
-Name - Specifies an array of names of modules to get.
-AllVersions - Indicates that you want to get all available versions of a module.
Finally, once we retrieve the specified Module(s) we can then with the pipe command “ | ” select the name and version to output to the console display.
Now in order to use the installed Module you first need to connect to your tenant, and to do that we use the following PnP command to connect to a SharePoint site.
4.At the command line enter the following and press Enter:
Connect-PnPOnline –Url https://[sitename].sharepoint.com –Credentials (Get-Credential)
Parameters
-Url - The Url of the site collection to connect to.
-Credentials - Credentials of the user to connect with.
The Windows PowerShell credential request window appears
5.Enter your Microsoft Credentials in the format [name]@domain.com and password and click the OK button
Your now connected to the [sitename].sharepoint.com site specified in the command line below
View all the PnP Cmdlets
Now let’s take a look at the commands that come with the SharePointPnPPowerShellOnline Module.
6.So, to list all the PnP cmdlets type the following command and press enter:
Get-Command -Module *PnP*
Now we see below several cmdlets related to SharePointPnPPowerShellOnline
Help with a Cmdlet
So now we are connected and looking at all the PnP cmdlets, digging a litter more, let’s see how to use the Connect-PnPHubsite cmdlet
This will enable you to learn more about the command and how it can be utilized.
7.At the command line the following and press enter:
Get-Help Connect-PnPHubsite
See the Help information for the Cmdlet Connect-PnPHubsite displayed below:
Get-Help is your best friend. From understanding what the command is used for, to getting examples of how to use the command is a great way to learn.
So, in this Journey we, checked the requirements for installing SharePoint Online PnP Module , Installed the Module and verified the installation. We then listed all the Modules to see what was installed with the SharePoint Online PnP Module . And finally, to get a little deeper we used the Get-Help command to get some detailed information on the use and examples of how to use the cmdlet.
Until next time 😊
PowerShell links