SharePoint PnP PowerShell

Hello Everyone from the Microsoft Ignite 2017 Conference!  One of the sessions I attended today was for the SharePoint 2017 PnP (Patterns and Practices), and they showed off one of the new Open Source tools I wanted to share with you:  The SharePoint PnP PowerShell Cmdlets:

You can grab the Cmdlets from Github here, and the Cmdlets are available for SP2013, SP2016, and SPOnline.  For this post, I’ll be focusing all of my examples on SPOnline.

Let’s Script!

So, to start, Fire up Powershell and install your module:

Install-Module SharePointPnPPowerShellOnline

Next, Connect to your SP Online site: (URL is an example only)

Connect-PnPOnline -Url https://dummy.sharepoint.com/sites/CommunicationSite

Great, we’re in!  Now what should we do?  The good news is, there are a TON of cmdlets that will let you get/set/remove/etc almost every thing in SharePoint.  But for this example, I’ll just go ahead a create a new list:

New-PnPList -Title “Awesome List” -Template “Custom” -EnableVersioning

This just provisions a simple Custom list with just the Title for a field (Like addding any normal Custom List from the GUI).  But what about fields?  We need more fields!

$List = Get-PnPList -Identity “Awesome List”

Add-PnPField -List $List -DisplayName “The String Field” -InternalName “TSField” -Type Text -AddToDefaultView

Ok, that’s Cool!  We added a list, added a field, but what about some Data?  Can we do that too?

Add-PnPListItem -List $List -ContentType “Item” -Values @{“Title” = “My Title”; “TSField” = “Totally Cool String Value”}

pnp1

This example is just the tiniest tip of the iceberg for all of the different cmdlets that are available.  You can find all of the cmdlets and examples here.  This is a huge game changer for SharePoint Development and Administration going forward.

Please check out some of my other articles to take a deeper dive into the product, and as always, please feel free to reach out to me at jo.karnes@centricconsulting.com

Happy Scripting!!!

One Comment Add yours

  1. Phil says:

    Thanks Jo! I like the simple & concise way you showed this. PS – I found a few other useful bits of information as well, primarily overcoming the delegation limits of PowerApps.

    Like

Leave a Reply