Deploying SharePoint lists the manual way
- From the Ribbon in SharePoint, connect each individual list you want to publish to Outlook.
- Right-click on each list in Outlook and share the list to an external email acount (to make the list URL visible)
- Copy the URL from the email.
- Create a new GPO for each department, using the “Default SharePoint Lists” policy. (User Configuration | Policies | Administrative Templates | Microsoft Outlook 2013 | Account Settings | SharePoint Lists | Default SharePoint Lists.) (If you haven’t already done so, you’ll need to copy the Administrative Templates to your Domain Controller’s Policy Definitions Folder).
- For each list, copy the URL and type in a name for the list that will display once it’s connected to Outlook.
Automating Deployment of SharePoint Lists with Powershell
- Obtaining the list URLs in Microsoft’s proprietary STSSync encoding format.
- Creating the nearly identical GPOs for each department.
- Copying over the URLs, and then typing in the name to describe each list. It was a remarkably tedious and error-prone process.
- There’s no built-in way to mass-remove or update a SharePoint list in Outlook.
I solved each of the problems above with PowerShell.
Generating an STSSyncURL with PowerShell from a SharePoint Online Site
As far as my research turned up, the STSSync URI is not available with built-in SharePoint Powershell methods. It is well documented, but it uses a proprietary encoding.
Here’s a sample URI:
Here’s what goes into the URI:
- A URI prefix and command which will be the same for all of our lists
- List Type: one of “calendar”, “contacts”, “discussions”, “documents”, or “tasks”
- GUID that uniquely identifies the list
- A “base” URL and “list” URL which point to the specific location of the list on the SharePoint site.
- A “site” and “list” name of your choice
Although the STSSync URL needs a Outlook content type that maps to a SharePoint list type, SharePoint doesn’t appear to expose this mapping externally. The best way that I identified is to check the Views associated with the list and look for the view titles associated with each type of list.
Here’s the code to generate STSSYNC URLs from a SharePoint Online site (a little too long to embed).
Automating GPO creation
Once we have our nicely formatted URLs, Powershell can also help us turn them into GPOs. As of Server 2012 R2, the cmdlets for manipulation GPOs in Powershell are limited to just setting values in the registry, but that’s enough to get our job done. As a bonus, GPOs that set registry values can coexist, allowing us to set up a “master” GPO with our shared lists, and not have it overwritten by a more specific GPO.
The stssyncurl script linked above outputs objects with three properties: “siteName”,”listName”,”stssyncurl”, suitable for piping to export-CSV. I created a second script that relies on those 3 properties, plus two more: gpoName and OU. To add those two values, I exported the output of the script to a CSV, added the two columns, and used Excel’s autofill to add in the appropriate GPO names and OUs. The GPO will only be created once. For subsequent rows in the CSV, the existing GPO will be updated.
Quick way to get the distinguishednames for your OUs:
get-adorganizationalunit -filter * -searchbase “ou=MYDEPARTMENTBASE,dc=Contoso,dc=com” | select distinguishedname
Great! Now when your users next close and reopen Outlook, they’ll see those SharePoint lists.
Cleaning up old SharePoint lists from Outlook
emoving the same list isn’t as easy.