Getting started with the Office 365 Developer Patterns and Practices PowerShell Cmdlets

The OfficeDev PnP Cmdlets are a set of cmdlets specifically designed to provision and modify artifacts in SharePoint Online. In this way they differ a bit from the PowerShell cmdlets provided by Microsoft which are mainly focused on administrative tasks. In this post I will introduce you to the basics of the cmdlets.

The cmdlets utilize CSOM behind the scenes, which means that you can run them on any computer that has access to your server over HTTP / HTTPS.

Update 2015-08-25: Updated links

Update 2015-08-06: If you want to see the cmdlets in action, please check out this video on Channel 9.


First you need to determine if you want to use the Cmdlets towards SharePoint Online / Office 365, or if you want to use them on-premises. There are two different builds of the cmdlets:

PnPPowerShellCommands15.msi for SharePoint 2013 On-Premises

PnPPowerShellCommands16.msi for SharePoint Online / Office 365.

You can download the releases here:

Download the appropriate package and run the install.


Accept the license agrement and click ‘Install’. The Advanced option allows you to pick if the cmdlets should be installed only for you or if you want to install them for all users on your computer (the latter requires that you have administrative rights with the account you are logged in with).

The install shouldn’t take more than a few seconds.

Using the cmdlets

The cmdlets are using CSOM behind the scenes. CSOM stands for Client Side Object Model and is the default SDK that developers use to build addins for SharePoint. A requirement to use this SDK is that the developer creates a so-called ‘context’ object. Think of a context object as a connection point to the server. In PowerShell we have to do something similar. We ‘connect’ the PowerShell session to your remote server with the Connect-SPOnline cmdlet:

When you enter the command, obviously with a functional url to your server and or Office 365, you will be prompted to enter your user credentials.

After you entered the Connect-SPOnline cmdlet you can execute all the other cmdlets available in the PnP Cmdlets module to perform various tasks.

For instance, to retrieve all the lists in the site:

To retrieve a specific list:


To view a property of the list:

Or to get an overview of all the properties available in the list:

Notice that not all properties might be ‘loaded’ yet. CSOM tries to be efficient when it comes to retrieving data from a SharePoint Server, and this means it will only retrieve those properties that have been explicitely requested. It will for instance never automatically retrieve values of a collection. Let me explain this with an example:

This will return an error as shown in the following screenshot:


This means that while the $list  object has a property called Views, you need to explicitely request it from the server (notice, there is also a Get-SPOView  cmdlet, which returns all the views for a list, but in this case we’re going to retrieve the views the ‘hard way’).

In order to explicitely show the views we need to tell the server to retrieve the collection, and for that we need a ClientContext object. Look at the following PowerShell snippet:


Whats commands are available?

Currently there are over 135 cmdlets available each focused on a specific tasks. It goes to far to describe them all, especially because we have built-in help in PowerShell for the cmdlets after all. To get an overview of all available cmdlets after you installed them, open PowerShell and enter:

This will list all available cmdlets.

If you want more details about a specific cmdlet, for instance about the Get-SPOList cmdlet, enter:

This will return an overview of the supported parameters, a short description per parameter and one or more examples (notice, not all PnP Cmdlets show examples, but most of them do).

If you want you to have a look at all the available cmdlets with your browser, head over here:

Missing functionality or want to contribute?

The cmdlet sourcd code is available in the following github repository: This is a sub repository for the PnP Repository available at In the latter repository you will find a wiki page at that should get you up and running with a pull request, which is the github way of proposing an addition and/or change.

You may also like...