Skip to content

Instantly share code, notes, and snippets.

View pkbullock's full-sized avatar
🎯
Focusing

Paul Bullock pkbullock

🎯
Focusing
View GitHub Profile
@pkbullock
pkbullock / Apply-UKLocaleTemplate.ps1
Last active April 26, 2022 11:50
Provision UK Locale using the Provisioning Engine
Connect-PnPOnline https://tenant.sharepoint.com/sites/yoursite
Apply-PnPProvisioningTemplate -Path "UK-Locale-Example-Provisioning-Template.xml"
@pkbullock
pkbullock / Get-GroupsTeamsExample.ps1
Created November 11, 2020 00:49
Get a list of groups that is associated to a team
Connect-PnPOnline -ClientId c53eb8da-8bdf-44f9-8718-1fb1bbbbbb `
-Thumbprint EC1E61510AEC35624AF78FEA763D00000000 `
-Tenant "tenant.co.uk" -Url "https://tenant.sharepoint.com"
$token = Get-PnPGraphAccessToken
# Create header with the access token
$header = @{ Authorization = "Bearer $($token)" }
#v1.0/Beta
@pkbullock
pkbullock / Register-AzureApp.ps1
Created November 11, 2020 00:35
Register Azure AD app using PnP PowerShell
Initialize-PnPPowerShellAuthentication -ApplicationName CaPa.Reporting `
-Tenant "tenant.co.uk" -Store CurrentUser -ValidYears 2 `
-CertificatePassword (ConvertTo-SecureString -String "password" -AsPlainText -Force)
# Output Example from PS:
#
# AzureAppId Certificate Thumbprint
# ---------- ----------------------
# c53eb8da-8bdf-44f9-8718-1fb1bbbbbb EC1E61510AEC35624AF78FEA763D00000000
#
@pkbullock
pkbullock / set-uk-locale-runbook.ps1
Last active November 5, 2020 22:39
Azure Automation script to set the SharePoint Site Locale
[CmdletBinding()]
Param
(
[string]$SiteUrl
)
# Refer to https://github.com/pnp/PnP-PowerShell/tree/master/Samples/Connect.AzureAutomation
# for setting up Azure Automation using an App Only connection to SharePoint Online
# Retrieves from the Azure Automation variables and certificate stores
@pkbullock
pkbullock / Set-UKLocale.ps1
Created November 5, 2020 22:10
Apply UK Locale using PnP PowerShell (Classic)
Connect-PnPOnline https://tenant.sharepoint.com/sites/yoursite
$LocaleId = 2057 # UK
$TimeZoneId = 2 # London
$web = Get-PnPWeb -Includes RegionalSettings,RegionalSettings.TimeZones
$timeZone = $web.RegionalSettings.TimeZones | Where-Object {$_.Id -eq $TimeZoneId}
$web.RegionalSettings.LocaleId = $LocaleId
$web.RegionalSettings.TimeZone = $timeZone
$web.Update()
Invoke-PnPQuery
@pkbullock
pkbullock / uk-locale-site-script.json
Last active November 5, 2020 22:09
UK Locale Site Script
{
"$schema": "schema.json",
"actions": [
{
"verb": "setRegionalSettings",
"timeZone":2,
"locale":2057,
"sortOrder":25,
"hourFormat":"24"
@pkbullock
pkbullock / install-ps.sh
Created October 10, 2020 13:31
Setup PowerShell on Raspbian
###################################
# Prerequisites
# Update package lists
sudo apt-get update
# Install libunwind8 and libssl1.0
# Regex is used to ensure that we do not install libssl1.0-dev, as it is a variant that is not required
sudo apt-get install '^libssl1.0.[0-9]$' libunwind8 -y
wget https://dotnet.microsoft.com/download/dotnet-core/scripts/v1/dotnet-install.sh
chmod +x dotnet-install.sh
# Ignore warnings
./dotnet-install.sh --channel LTS --architecture arm --install-dir ~/cli
# Allows running dotnet anywhere - thanks to
# this article https://edi.wang/post/2019/9/29/setup-net-core-30-runtime-and-sdk-on-raspberry-pi-4
sudo nano .profile
export DOTNET_ROOT=$HOME/cli
@pkbullock
pkbullock / Setup-AzureADApp.ps1
Created July 31, 2020 11:48
Setting up Azure AD App for use with SharePoint
$Tenant = "yourtenant.onmicrosoft.com"
$AppName = "PnP-PowerShell Automation Example",
$CertificatePassword = "1234", # <-- Use a better one than this, nice a super complex
$ValidForYears = 2,
$CertCommonName = "PnP-PowerShell Automation Example",
$location = Get-Location # Get the location of the script to copy the script locally
Initialize-PnPPowerShellAuthentication -ApplicationName $AppName -Tenant $Tenant -OutPath $location `
-CertificatePassword (ConvertTo-SecureString -String $CertificatePassword -AsPlainText -Force) -ValidYears $ValidForYears `
-CommonName $CertCommonName
@pkbullock
pkbullock / Set-PageNotFoundProperty.ps1
Last active July 31, 2020 10:27
Set 404 Property on SharePoint site
$tenant = "<tenant>"
$site = "<site>"
$siteUrl = "https://$($tenant).sharepoint.com/sites/$($site)"
Write-Host "Setting 404 page at $($siteUrl)..."
# Connect to SharePoint Online with PnP PowerShell library
Connect-PnPOnline $siteUrl -UseWebLogin