Want to know how to work with PnP PowerShell SharePoint Online? In this tutorial, we will discuss how to install PnP PowerShell in Windows 10 machine, and then we will discuss how to connect with SharePoint Online site using PnP PowerShell commands.
SharePoint Online tutorial contents:
- What is PnP PowerShell
- How to install PNP PowerShell in Windows 10 for SharePoint online
- Install PnP PowerShell for SharePoint 2013
- How to install PnP PowerShell for SharePoint 2016
- Install PnP PowerShell for SharePoint 2019
- Check PnP PowerShell Version
- Uninstall All Versions on PnP PowerShell
- Connect to SharePoint Online Site using PnP PowerShell
- Download and Install PnP PowerShell from repository
What is PnP PowerShell
PnP stands for patterns and practices which contain various PowerShell commands as a library known as PnP Powershell which we can use to perform complex actions in SharePoint.
These commands internally use CSOM ( client-side object model) and we can use PnP PowerShell with SharePoint Online as well as SharePoint on-premises versions like SharePoint 2013, SharePoint 2016, and Sharepoint 2019.
If you are using Windows 10 OS, then we can easily install PnP PowerShell for SharePoint Online.
Open Windows PowerShell in administrator mode and run the below command:
Install-Module SharePointPnPPowerShellOnline
Almost every month Microsoft releases new PNP PowerShell cmdlets and it is easier to update to the latest version of PnP Powershell.
To update PnP PowerShell, run the below command and it will install the latest version of PnP Powershell.
Update-Module SharePointPnPPowerShellOnline
To uninstall PnP PowerShell for SharePoint Online run the below command.
Uninstall-Module SharePointPnPPowerShellOnline
If you are working with SharePoint 2013 then you can run the below command to install PnP PowerShell which will work for SharePoint on-premises version 2013.
Install-Module SharePointPnPPowerShell2013
Update PnP PowerShell for SharePoint 2013:
Update-Module SharePointPnPPowerShell2013
Remove or Uninstall PnP PowerShel for SharePoint 2013:
Uninstall-Module SharePointPnPPowerShell2013
The same way if you want to install PnP PowerShell for SharePoint 2016 or to connect to SharePoint 2016 then run the below command:
Install-Module SharePointPnPPowerShell2016
Update PnP PowerShell for SharePoint 2016:
Update-Module SharePointPnPPowerShell2016
Remove or Uninstall PnP PowerShel for SharePoint 2016:
Uninstall-Module SharePointPnPPowerShell2016
SharePoint 2019 is the latest version of SharePoint on-premises. If you want to connect to SharePoint 2019 sites from your Windows 10 operating system, then run the below command.
Install-Module SharePointPnPPowerShell2019
If you want to update PnP PowerShell for SharePoint 2019 run the below command in Windows PowerShell:
Update-Module SharePointPnPPowerShell2019
Remove or Uninstall PnP PowerShel for SharePoint 2019:
Uninstall-Module SharePointPnPPowerShell2019
Check PnP PowerShell Version
Run the below command to check which version is installed in the system:
Get-Module SharePointPnPPowerShellOnline -ListAvailable | Select-Object Name,Version | Sort-Object Version -Descending
Uninstall All Versions on PnP PowerShell
You can use the below command in PowerShell to uninstall all the versions of PnP PowerShell installed in the system.
Uninstall-Module SharePointPnPPowerShellOnline -AllVersions
Like in the above picture, it will install both the versions of PnP PowerShell from my system.
You can run the below command to connect to SharePoint Online sites from PnP Powershell.
Connect-PnPOnline –Url https://tsinfo.sharepoint.com/sites/SharePointSky –Credentials (Get-Credential)
If you are using multi Factor authentication then you can run the below command to connect to SharePoint online send from PnP PowerShell:
Connect-PnPOnline –Url https://tsinfo.sharepoint.com/sites/SharePointSky –UseWebLogin
Now, you can get all the lists from a SharePoint site by using below PnP PowerShell command:
Get-PnPList
You can see the output like below:
There are lots of PnP PowerShell commands are available, you can check in this URL.
Or you can also run the below cmdlets:
Get-Command -Module SharePointPnPPowerShell*
Download and Install PnP PowerShell from repository
Apart from running the commands online we can also install PNP PowerShell from setup files that are available in the PnP PowerShell repository.
You can visit this URL and here you will be able to see .msi files that are available for SharePoint Online and SharePoint 2013/2016/2019.
You can also download the source code in zip file format.
Once you download the .msi file you can then install and use PnP PowerShell.
- How to create a communication site in SharePoint using PowerShell
- Create SharePoint Online List Programmatically using PnP CSOM
- SharePoint Online PowerShell: Disable versioning in a document library (PnP PowerShell)
- How to check if a list exists in SharePoint Online site using PNP PowerShell
- Remove all items from a SharePoint Online list using PnP PowerShell
- the term ‘get-spweb’ is not recognized as the name of a cmdlet function
Here, we learned, what is PnP PowerShell? How to install and use PnP PowerShell for SharePoint Online or SharePoint 2013/2016/2019. I hope you got an idea on how to install PnP PowerShell and connect with SharePoint Online sites.
I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site EnjoySharePoint.com