Skip to content

Instantly share code, notes, and snippets.

View garrytrinder's full-sized avatar
👨‍💻
CLI for Microsoft 365

Garry Trinder garrytrinder

👨‍💻
CLI for Microsoft 365
View GitHub Profile
@garrytrinder
garrytrinder / Get-PnPWeb.ps1
Last active December 15, 2018 17:55
Example of a very basic Azure Automation Runbook that outputs a JSON object
Param(
[Parameter(Mandatory=$true)]
[string]$SiteUrl
)
# ensure that any error stops the job
$ErrorActionPreference = "Stop"
# create connection to SharePoint site
Connect-PnPOnline -Url $SiteUrl -Credentials (Get-AutomationPSCredential -Name "Lundhill")
@garrytrinder
garrytrinder / Update-PowerAppOwner.ps1
Last active May 25, 2018 10:03
Script that updates the Owner of a PowerApp
# Requires Azure Powershell
# https://docs.microsoft.com/en-us/powershell/azure/install-azurerm-ps?view=azurermps-6.1.0
# Requires PowerShell support for PowerApps (preview)
# https://docs.microsoft.com/en-us/powerapps/administrator/powerapps-powershell
# Step 1 - Setup PowerShell support for PowerApps
Import-Module .\Microsoft.PowerApps.Administration.PowerShell.psm1 -Force
Import-Module .\Microsoft.PowerApps.PowerShell.psm1 -Force
Get-ChildItem . | Unblock-File
@garrytrinder
garrytrinder / Get-SPOSiteTemplateExperience.ps1
Created December 15, 2018 17:45
Identify if SPO Sites are Modern or Classic
Get-SPOSite | Select-Object Url,Title,Template, @{Expression={($_.Template -like "STS#3") -or ($_.Tem
plate -like "GROUP#0") -or ($_.Template -like "SITEPAGEPUBLISHING#0")};label="Modern"} | Sort-Object @{Expression={$_.Mo
dern};Descending=$True}, @{Expression={$_.Url};Descending=$False}
@garrytrinder
garrytrinder / Apply-PnPProvisioningTemplate.ps1
Last active December 15, 2018 21:15
Azure Automation Basic PnP Provisioning Runbook
Param(
[Parameter(Mandatory=$true)]
[string]$CredentialName,
[Parameter(Mandatory=$true)]
[string]$SiteUrl,
[Parameter(Mandatory=$true)]
[xml]$Template
)
# Store XML Template as local file
@garrytrinder
garrytrinder / New-PnPTenantSite.ps1
Last active December 15, 2018 21:15
Azure Automation PnP New Site Runbook
Param(
[Parameter(Mandatory=$true)]
[string]$CredentialName,
[Parameter(Mandatory=$true)]
[string]$TenantAdminUrl,
[Parameter(Mandatory=$true)]
[string]$SiteTitle,
[Parameter(Mandatory=$true)]
[string]$SiteDescription,
[Parameter(Mandatory=$true)]
@garrytrinder
garrytrinder / Remove-PnPListItemsFromList.ps1
Created December 24, 2018 16:03
Removes all list items from a SharePoint List
Param(
[Parameter(Mandatory=$true)]
[string]$ListName
)
Get-PnPListItem -List $ListName | ForEach-Object { Remove-PnPListItem -List $ListName -Identity $_ -Force; Write-Host "Removed item $($_.Id)" }
@garrytrinder
garrytrinder / New-PnPTenantSite.ps1
Created January 23, 2019 14:57
Azure Automation Runbook
Param(
[Parameter(Mandatory=$true)]
[string]$CredentialName,
[Parameter(Mandatory=$true)]
[string]$TenantAdminUrl,
[Parameter(Mandatory=$true)]
[string]$SiteTitle,
[Parameter(Mandatory=$true)]
[string]$SiteDescription,
[Parameter(Mandatory=$true)]
@garrytrinder
garrytrinder / PowerAppsConfig.js
Last active January 29, 2019 10:51
Sample configuration for PowerApp development
Set(
gblFont,
Font.'Open Sans'
);
Set(
gblColor,
{
Primary: {
_700: RGBA(
29,
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: Garry Trinder
-- Create Date: 17/02/2019
-- Description: Truncates TimeEntry table and imports data from Azure Storage
-- =============================================
CREATE PROCEDURE ImportTimeEntries @Run bit
CREATE MASTER KEY ENCRYPTION BY PASSWORD='<insert strong password>';
CREATE DATABASE SCOPED CREDENTIAL harvestdata001credential
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = '<insert shared access signature>';
CREATE EXTERNAL DATA SOURCE harvestdata001
WITH ( TYPE = BLOB_STORAGE,
LOCATION = 'https://harvestdata001.blob.core.windows.net',
CREDENTIAL= harvestdata001credential);