Installing PnP PowerShell for SharePoint Online and Azure Cloud Shell
Table of contents
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?
It is a cross-platform PowerShell, and it is a .NET Core 3.1 / .NET Framework 4.6.1 based PowerShell Module providing over 600 cmdlets that work with Microsoft 365 environments such as SharePoint Online, Microsoft Teams, Microsoft Project, Security & Compliance, Azure Active Directory, and more.
Why do we need PnP PowerShell?
Microsoft has provided additional PnP PowerShell cmdlets to the SharePoint Online cmdlets. I believe the PnP PowerShell cmdlets are developer-focused and provide the means to manage artifacts in SharePoint, such as lists, views, fields, content types, and so on.
PnP PowerShell internally implements the Client-Side object model for its operations. This makes the operations adaptable. The same set of operations can be executed on any SharePoint environment. Using PnP PowerShell, a single line of code is used to access an object on SharePoint, wherein with the 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.
It is recommended to use PowerShell 7.x, which can be installed by following these instructions (although most of the cmdlets should work under PowerShell 5.x as well): First, open the Windows PowerShell console as an Administrator and do the following to install PnP.PowerShell module:
Uninstall the Legacy SharePointPnPPowerShellOnline Module if installed already:
Uninstall-Module SharePointPnPPowerShellOnline -Force –all versions
Install the New PnP PowerShell Module with the following code:
Install-Module PnP.PowerShell
If you want to install or update to the latest built pre-release of PnP PowerShell, run the following code:
Install-Module -Name “PnP.PowerShell” -AllowPrerelease
Connect to the SharePoint Online Admin Centre of your tenant with the following code:
Connect-PnPOnline -Url https://tenant-admin.sharepoint.com -Interactive
The following command will give you a list of PnP PowerShell commands to design your SharePoint website:
Get-Command -Module PnP
In case you would like to uninstall PnP PowerShell again, you can run the following:
Uninstall-Module -Name “PnP.PowerShell”
How to Use PnP PowerShell in the Azure Cloud Shell
Open the Azure Cloud Shell at https://shell.azure.com and select PowerShell as your shell and enter:
Install-Module -Name “PnP.PowerShell”
The next time you open the Azure Cloud Shell, PnP PowerShell will be available for you to use.
In Summary
PnP PowerShell proves to be an indispensable tool in SharePoint development services, allowing you to automate repetitive tasks, enhance productivity, and maintain consistency across your SharePoint environment. By following this tutorial to install PnP PowerShell and exploring its resourceful applications, you're well on your way to becoming proficient in SharePoint development and administration with PnP PowerShell.
Subscribe to my newsletter
Read articles from CloudStakes Technology directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
CloudStakes Technology
CloudStakes Technology
CloudStakes Technology Pvt. Ltd. is a leading cloud solutions providing company located in India, with other three branches in the UK, Australia and Canada. We are serving in this industry for more than 6 years and helping clients to achieve their industry level innovations. Our all solutions are built with perfectly executed strategies and approaches. We thrive to provide our digital solutions to global businesses and desires to be an essential part of digital transformation and technology innovation. Our all solutions are inclined with clients’ industry standards, and 24/7 dedicated support will help them stay competitive in this forward driving world.