Skip to content

Instantly share code, notes, and snippets.

Avatar

Bob German BobGerman

View GitHub Profile
@BobGerman
BobGerman / Setup-ModernSiteSample.ps1
Created Sep 22, 2017
Provisioning a modern team site with PnP PowerShell
View Setup-ModernSiteSample.ps1
Connect-PnPMicrosoftGraph -Scopes "Group.ReadWrite.All","User.Read.All"
$group = New-PnPUnifiedGroup -DisplayName "xxx" -Description "xxx" -MailNickname "xxx"
-Members "user@tenant.onmicrosoft.com" -IsPrivate
Connect-PnPOnline $group.SiteUrl
# Here you would normally apply a Provisioning Template to create lists, libraries, web parts etc.
# based on a "template" site. Instead, I just want to show placing a couple web parts in a
# 2-column section to show how that works:
@BobGerman
BobGerman / Setup-SiteClassificationsSample.ps1
Created Sep 22, 2017
Sample PowerShell to set up SP Online site classifications
View Setup-SiteClassificationsSample.ps1
$me = Get-Credential
Import-Module AzureADPreview
Connect-AzureAD -Credential $me
# Create the new setting
$template = Get-AzureADDirectorySettingTemplate | Where-Object {$_.DisplayName -eq "Group.Unified"}
$setting = $template.CreateDirectorySetting()
$setting["UsageGuidelinesUrl"] = "http://www.microsoft.com/"
$setting["ClassificationList"] = "Secret, Confidential, Internal, Public"
@BobGerman
BobGerman / csomHelper.csx
Last active Nov 23, 2020
Sample code for calling SharePoint CSOM from an Azure Function
View csomHelper.csx
using Microsoft.IdentityModel.Clients.ActiveDirectory;
using Microsoft.SharePoint.Client;
using System.Security.Cryptography.X509Certificates;
public static class csomHelper {
private static string ClientId = "<fill in app ID>";
private static string Cert = "myCert.pfx"; // Fill in name of your cert file and upload it
private static string CertPassword = "<fill in cert password>"; // TODO: Explore more secure place for this
private static string Authority = "https://login.windows.net/<tenant>.onmicrosoft.com/";
@BobGerman
BobGerman / WidgetHelperUse.ts
Last active Aug 13, 2019
This service provides the on-page content (_spPageContextInfo and __REQUESTDIGEST) often used when making REST calls in JavaScript from a SharePoint page. This content is not provided on Modern pages with the SharePoint Framework, requiring updates to any REST calls that may have depended on it. This service dynamically populates the data on any…
View WidgetHelperUse.ts
// (within a SharePoint Framework web part)
import { WidgetHelper } from './services/widgetHelper';
// ...
public render(): void {
var helper = new WidgetHelper(this.context);
helper.ensureClassicPageProps(true).then (() => {
const element: React.ReactElement<IEventsProps > = React.createElement(
Events,