Created
November 1, 2016 18:01
-
-
Save nonprofittechy/80272f00ebe8a11f57bf145da9a4b268 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Create GPOs that set the Administrative Template for "Default SharePoint Lists" as specified in a CSV. | |
The CSV can update (or create) multiple GPOs based on the column "gpoName". | |
.DESCRIPTION | |
The input CSV has 5 mandatory columns: | |
gpoName : Name of the GPO to update | |
ou : the name of the OU to link the GPO to | |
siteName : Site name on Sharepoint | |
listName : Name of the listName | |
stssyncurl : properly formatted STSSync URL. See: https://msdn.microsoft.com/en-us/library/dd957390(v=office.12).aspx | |
The format of the list's name when connected to Outlook will be "siteName - listName" | |
The CSV I've used was partially generated by another script, get-allspolists.ps1 which generates the STSSYnc URLs in the correct format. | |
.NOTES | |
Author : Quinten Steenhuis | |
#> | |
Param( | |
[String]$csvpath = Read-Host -Prompt "Path to CSV: ") | |
$stssyncrows = import-csv $csvpath | |
function test-gpo ($gpo) { | |
return [bool](get-gpo -name $gpo -ea silentlycontinue) | |
} | |
$gpos = @() | |
foreach ($row in $stssyncrows) { | |
if ((-not ($gpos -match $row.gponame)) -or (-not (test-gpo $row.gponame)) ) { | |
new-gpo -name $row.gpoName | |
new-gplink -name $row.gpoName -target $row.OU | |
$gpos += $row.gpoName | |
} | |
$valueName = ($row.siteName + " - " + $row.listName) | |
$key = "HKCU\Software\Policies\Microsoft\Office\15.0\outlook\options\accounts" | |
$gp = get-gpo -name $row.gpoName | |
set-gpprefregistryvalue -guid $gp.ID -context user -action update -type string -key $key -value $row.stssyncurl -valuename $valueName | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment