Skip to content

Instantly share code, notes, and snippets.

Avatar

Phil Harding phillipharding

View GitHub Profile
@phillipharding
phillipharding / body.json
Created Oct 17, 2020 — forked from garrytrinder/m365-identity.sh
Create custom Azure AD identity for use with CLI for Microsoft 365 using Azure CLI
View body.json
{
"isFallbackPublicClient": true,
"publicClient": {
"redirectUris": [
"https://login.microsoftonline.com/common/oauth2/nativeclient"
]
},
"web": {
"implicitGrantSettings": {
"enableIdTokenIssuance": false
View Get Taxonomy Terms Hierarchy using PnPJS
import { sp } from "@pnp/sp/presets/all";
import "@pnp/sp/taxonomy";
import { taxonomy, ITerm, ITermData } from "@pnp/sp-taxonomy"
(async () => {
interface ITermDataNode {
Id: string;
ParentTermId?: string;
Name: string;
Path: string;
@phillipharding
phillipharding / Create new ClientsidePage using PnPJS.ts
Last active Sep 16, 2020
Create new ClientsidePage using PnPJS
View Create new ClientsidePage using PnPJS.ts
import { sp, ClientsidePageFromFile, PromotedState, IListItemFormUpdateValue, IClientsidePage, IFileInfo } from "@pnp/sp/presets/all";
console.clear();
function SafeFilename(fileName: string, convertToLower?: boolean): string {
const name = (fileName || "")
.replace(/[^ a-zA-Z0-9-_]*/gi, "")
.replace(/ /gi, "-")
.replace(/-*$/gi, "")
.replace(/[-]{2,}/gi, "-");
return convertToLower ? name.toLowerCase() : name;
@phillipharding
phillipharding / Search for Modern News Page Content using PnPJS.ts
Created Sep 11, 2020
Search for Modern News Page Content using PnPJS
View Search for Modern News Page Content using PnPJS.ts
import { sp, SearchResults, SearchQueryInit, ISearchResult } from "@pnp/sp/presets/all";
console.clear();
function parseUserFormattedString(ownerString) {
const owners = ownerString.split(";")
.map( (owner) => {
const parts = owner.trim().split("|");
const oidstr = parts.splice(2,3).join("").trim();
const oids = oidstr.split(" ");
return {
View Create and Locate an Item in a JSON Tree
json = [
{
key: 1,
id: 1,
label: "Parent #1",
isexpanded: false,
children: [
{
key: 11,
id: 11,
@phillipharding
phillipharding / Get Paged Items from a Large List using RenderListDataAsStream
Last active Jul 14, 2020
Gets Items from a Large Document Library/List (over 5000 items) using a Paged RenderListDataAsStream
View Get Paged Items from a Large List using RenderListDataAsStream
import { sp } from "@pnp/sp/presets/all";
(async () => {
console.clear();
const doPagedQuery = (folder: string, rowLimit: number, scope: "Files"|"Folders", pageToken?: string) => {
const list = sp.web.getList('/sites/EDMS_InformationGovernance/Shared%20Documents');
return list.renderListDataAsStream({
ViewXml: `
<View Scope="RecursiveAll">
View NVM Commands.md

NVM version

nvm --version

List versions of Node installed

nvm ls --no-alias

List current version of Node

nvm current

Use the specified version of Node

View Matching Invalid Characters in Team & Channel Names.md

~ # % & * { } + \ / : < > ? | " .

REGEX

[~#%&*{}+\\/:<>?|'".]+
const hasInvalidCharacters = teamName.match(/[~#%&*{}+\\/:<>?|'".]+/gi);
@phillipharding
phillipharding / Remove .DS_Store files.sh
Created Apr 28, 2020
Recursively removes .DS_Store files
View Remove .DS_Store files.sh
## Recursively Remove .DS_Store
# Show
find . -name '.DS_Store' -type f
# Remove
find . -name '.DS_Store' -type f -delete
@phillipharding
phillipharding / Get O365 Groups using AdalJS and Graph on Classic SP Page.js
Last active Apr 1, 2020
Get Office 365 Groups and Current User Profile using the Graph API and AdalJS to acquire access tokens
View Get O365 Groups using AdalJS and Graph on Classic SP Page.js
console.clear();
/* Logging levels
0: Error
1: Warning
2: Info
3: Verbose
*/
(function() {
/* LOAD ADAL.JS onto the page