My experiences with the Office Dev PnP PowerShell cmdlets

Currently I am rolling out a student portal for a client who is in education. I have followed Office Dev PnP for a long time now, but until this project I didn’t have a chance to play with it.

officedev

Rolling out the student portal for my client is a pretty big job, because it involves a lot of configuration. Every education team – 140 teams in total – will get a site with a document library, a links list and a page library to publish news. We chose to do this with a CSOM script because our experiences with PowerShell cmdlets, which were available to us at the time, were not that good.

*Office Dev Pnp PowerShell cmdlets *

There were still some parts of the configuration that were not included in the CSOM script, so I decided to do as much as possible for the parts that weren’t covered by the script with the Office Dev PnP PowerShell cmdlets.

We are in a situation where the PR & Marketing department is in control of the intranet-content. Adding a site, Web parts, lists and document libraries is one of their responsibilities. While they are trained to do this, it’s not the ideal situation to do this by hand every time.

Here you can see a list being made, a content type being added to the list, a content type is removed from the list, a view is removed and then a view is added.

adding-list-powershell-2

To make this process go faster and with fewer errors, I used the PowerShell cmdlets provided by the Office Dev PnP team. I started writing some PowerShell scripts to add a list, adding a couple of content types to that list, add multiple views, etcetera. Before, I was used to using write-line and read-line a lot, but I needed something else this time, because the PR & Marketing team isn’t allowed to use PowerShell themselves. So, I had to come up with something else.

What options did I have?

  • I could give the PR and Marketing department my script and let them edit my variables: I would like this option, but then the PR and Marketing department could accidentally adjust something in the script.
  • I could change the variables myself every time: This would cost a lot of time, so this is not a good option at all…
  • Or I could import an XML file the PR & Marketing department fills in every time they need new sites

XML

I thought of an add-in, but that was too much of an effort for what we were doing. When thinking of an easy-to-use solution for this, a colleague of mine said it could easily be done by using XML. The process is now very easy: the PR & Marketing department edits the XML, sends it to the SharePoint team and the SharePoint team runs the PowerShell script, which uses the XML provided by PR & Marketing as an input.

Most loved cmdlet

I really love the Connect-SPOnline cmdlet because of the way you can use your credentials. Normally I used to insert my credentials every time I was running a script. Now you can add a general reference to your credential store and use that reference to connect to Office 365. It saves a lot of time! Brilliant!

connect

Things to consider

During tests with the scripts, I found out there were still some issues with the Office Dev PnP PowerShell cmdlets, but for most of them I turned to Erwin van Hunen and asked if they could be fixed. I was really impressed with how fast Erwin fixed the issues.

The PowerShell cmdlets are useful right now for small projects, but they could use a bit more polished. For example: I used the Add-SPONavigationNode cmdlet to add a navigation node to the global navigation, but I couldn’t set the audience (students/teachers). I would love to see the Office 365 Developer Patterns and Practices Core Team add these kind of properties so we don’t have to set these properties manually. Some things I wanted weren’t even available in CSOM, but I would love to see these cmdlets develop into something we used for almost every project. So far, the Office Dev PnP project already makes my life a lot easier and that’s something I am really thankful for!

Comments

comments powered by Disqus