Time-Saving PowerShell Script for SharePoint 2013 Certs

As a SharePoint dev, I share my time-saving PowerShell script for registering self-signed certificates. Learn how to speed SharePoint 2013 on-prem app dev.

A while ago I posted a PowerShell script that I use to register a self-signed certificate that started out like this :

If you’ve tried creating a provider hosted app for SharePoint 2013 on-prem (not in Office 365) you know you likely need to go through some gyrations to set it up for high trust using the server-to-server (S2S) protocol. There’s a great article on MSDN that walks you through the details of this (linked below), but it’s a pain to have to type all that. Hopefully Visual Studio 2012’s SharePoint 2013 & Office 2013 Developer Tools will make our lives easier when we get to RTM, but for now in Beta 2 / Preview, I find it to be a pain.

That script required you to create & export the self-signed certificate (.cer) and associated private key (.pfx) using IIS. I always intended to script out the whole thing with Windows PowerShell… and now it’s finally done. Here’s what I added to the script:

Update (December, 20, 2014): I finally got around to updating my scripts… I deleted the old script I had here on my site & have added the following two. The first one will create a self-signed certificate which you can use in your local dev. The second one will set up an STS for S2S.

This generates the following…

PowerShell Results

PowerShell Results

You can see from the first line in the screenshot what you need to pass in to get this to work. If you look at the header in the script you’ll see a list of all the parameters and sample values. The script also lets you specify the certificate to use rather than letting it create one for you.

Introducing the first installment to Critical Path Training’s SharePoint 2013 Script Library. This is located in the Critical Path Training Members section of our site, specifically in the Code Samples section. A sign in is required, but it’s free to set one up. The script PrepareS2SApp.ps1 does almost everything for you.

Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a web & cloud developer with a focus on Microsoft Azure & Microsoft 365. He’s received Microsoft’s MVP award every year since 2005 and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s the founder of Voitanos and is dedicated to helping you be the best Microsoft 365 web & cloud developer. He lives with his wife & two kids in Florida.

Share & Comment