Skip to content

Instantly share code, notes, and snippets.

View waldekmastykarz's full-sized avatar
🥑
Microsoft 365

Waldek Mastykarz waldekmastykarz

🥑
Microsoft 365
View GitHub Profile
@waldekmastykarz
waldekmastykarz / index.js
Created August 30, 2020 12:34
Get GitHub repo contributors from last month
const axios = require('axios').default;
// define date ranges to process commits
const now = new Date();
const pastMonthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth() - 1, 1));
const currentMonthStart = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), 1));
console.log('Retrieving PRs...');
axios
.get(`https://api.github.com/repos/pnp/cli-microsoft365/pulls?state=closed&sort=updated&direction=desc&per_page=100`)
@waldekmastykarz
waldekmastykarz / archive-mail.sh
Created August 6, 2020 18:19
Move Outlook emails from Inbox to Archive
OFFICE365CLI_AADAPPID=31... OFFICE365CLI_TENANT=b4... m365 outlook message list --folderName inbox -o json --query '[].id' > emails.txt
i=0
cat emails.txt | jq -c '.[]' | while read msgId; do
i=$((i+1))
echo "Archiving $i..."
OFFICE365CLI_AADAPPID=31... OFFICE365CLI_TENANT=b4... m365 outlook message move --sourceFolderName inbox --messageId $msgId --targetFolderName archive
done
@waldekmastykarz
waldekmastykarz / cli.sh
Created July 17, 2020 13:39
Run CLI for Microsoft 365 with specific AAD app
OFFICE365CLI_AADAPPID= OFFICE365CLI_TENANT= m365 login
@waldekmastykarz
waldekmastykarz / set-owners.sh
Created February 24, 2019 15:59
Sets the specified user as site owner for a number of test sites
for i in {1..10000};
do
label="$i"
if (( $i < 10 )); then
label="0$label"
fi
if (( $i < 100 )); then
label="0$label"
fi
if (( $i < 1000 )); then
@waldekmastykarz
waldekmastykarz / create-sites.sh
Created February 24, 2019 15:58
Creates a number of modern team sites using the Office 365 CLI
for i in {1..10000};
do
label="$i"
if (( $i < 10 )); then
label="0$label"
fi
if (( $i < 100 )); then
label="0$label"
fi
if (( $i < 1000 )); then
@waldekmastykarz
waldekmastykarz / create-cert.sh
Last active June 18, 2020 10:56
Create certificate for AAD app for app-only authN. Generated certificate is not password-protected
openssl genrsa -out localhost.pfx 2048
openssl req -new -key localhost.pfx -out localhost.csr
openssl x509 -req -in localhost.csr -signkey localhost.pfx -out localhost.pem
@waldekmastykarz
waldekmastykarz / modern-pages.txt
Created August 29, 2018 05:31
Test SharePoint Framework web parts on modern pages
?loadSPFX=true&debugManifestsFile=https://localhost:4321/temp/manifests.js
@waldekmastykarz
waldekmastykarz / test-circleci.sh
Created August 26, 2018 10:41
Test CircleCI build in Docker
docker run -it --rm -v $PWD:/usr/src circleci/node:8.11.2
@waldekmastykarz
waldekmastykarz / mkdocs.sh
Last active December 22, 2019 18:48
MkDocs Docker
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs squidfunk/mkdocs-material:3.1.0
@waldekmastykarz
waldekmastykarz / create-projects.sh
Last active August 31, 2022 06:55
Bash script to create a set of SharePoint Framework projects
#!/usr/bin/env bash
set -o errexit
set -o pipefail
set -o nounset
#set -o xtrace
version=$1
cmd_base='yo @microsoft/sharepoint --solutionName spfx --component-name HelloWorld --component-description HelloWorld --skip-install'
cmd_v1_1="$cmd_base --no-skip-feature-deployment"