Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Paul Bullock pkbullock

🎯
Focusing
View GitHub Profile
@pkbullock
pkbullock / Get-GroupsTeamsExample.ps1
Created Nov 11, 2020
Get a list of groups that is associated to a team
View Get-GroupsTeamsExample.ps1
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 Nov 11, 2020
Register Azure AD app using PnP PowerShell
View Register-AzureApp.ps1
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 Nov 5, 2020
Azure Automation script to set the SharePoint Site Locale
View set-uk-locale-runbook.ps1
[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 / Apply-UKLocaleTemplate.ps1
Last active Nov 5, 2020
Provision UK Locale using the Provisioning Engine
View Apply-UKLocaleTemplate.ps1
Connect-PnPOnline https://tenant.sharepoint.com/sites/yoursite
Apply-PnPProvisioningTemplate -Path "UK-Locale-Example-Provisioning-Template.xml"
@pkbullock
pkbullock / Set-UKLocale.ps1
Created Nov 5, 2020
Apply UK Locale using PnP PowerShell (Classic)
View Set-UKLocale.ps1
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
View uk-locale-site-script.json
{
"$schema": "schema.json",
"actions": [
{
"verb": "setRegionalSettings",
"timeZone":2,
"locale":2057,
"sortOrder":25,
"hourFormat":"24"
@pkbullock
pkbullock / install-ps.sh
Created Oct 10, 2020
Setup PowerShell on Raspbian
View install-ps.sh
###################################
# 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
View install-dotnet-raspberrypi.sh
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 Jul 31, 2020
Setting up Azure AD App for use with SharePoint
View Setup-AzureADApp.ps1
$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 / Get-GraphCalls.ps1
Last active Jun 11, 2020
Making Graph calls with PnP PowerShell via App-Only Certificates
View Get-GraphCalls.ps1
Connect-PnPOnline -ClientId "<AppId>" -CertificatePath "<C:\...\Cert\cerificate.pfx>" `
-CertificatePassword (ConvertTo-SecureString -AsPlainText "<pw>" -Force) `
-Url "https://<tenant>.sharepoint.com/sites/TheCoolTeam" -Tenant "<id>"
$token = Get-PnPGraphAccessToken
# Create header
$header = @{
Authorization = "Bearer $($token)"
}