Skip to content

Instantly share code, notes, and snippets.

@dmadelung
dmadelung / sitedesignsitescriptspowershell.ps1
Last active March 19, 2019 21:34
Site Design & Site Scripts PowerShell
<#
README
The scripts are not meant to be ran together.
These are a collection of scripts that can be pieced together.
Each section below comments can perform a specific action.
Update your info
CREATOR - Drew Madelung
LAST UPDATED - 3/15/2019
#>
$sitedesign = Get-SPOSiteDesign | where {$_.Title -eq "Advanced Design"}
$existingsitescripts = $sitedesign.SiteScriptIds
Set-SPOSiteDesign -Identity $sitedesign.Id -SiteScripts $existingsitescripts, $sitescript.Id
$terms = @()
#set terms
$terms = "Term1","Term2"
#set mm field
$mmfield = 'MM'
#get term info
$tg = Get-PnPTermGroup -Identity "Site Collection - drewmadelung.sharepoint.com"
$list = Get-PnPList "List"
$view = Get-PnPView -List $list -Identity "All Documents"
$vto = $view.TypedObject
$view.Context.Load($vto)
$view.Context.ExecuteQuery()
$vto.ViewQuery = "<OrderBy><FieldRef Name=`"Modified`" Ascending=`"False`" /></OrderBy><Where><Neq><FieldRef Name=`"DocumentState`" /><Value Type=`"Text`">Obsolete</Value></Neq></Where>"
$view.Update()
$view.Context.ExecuteQuery()
add-type -Path "C:\Users\dmadelung\SPCSOM\Microsoft.SharePoint.Client.dll"
add-type -Path "C:\Users\dmadelung\SPCSOM\Microsoft.SharePoint.Client.Runtime.dll"
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext("https://domain-my.sharepoint.com/personal/drew_drewmadelung_com")
$ss = Read-Host -Prompt "Enter password" -AsSecureString
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials("drew@drewmadelung.com", $ss)
$web = $ctx.Web
$ctx.Load($web)
$ctx.ExecuteQuery()