Skip to content

Instantly share code, notes, and snippets.

View pkskelly's full-sized avatar

Pete Skelly pkskelly

View GitHub Profile
@pkskelly
pkskelly / SplitPascalCaseVIewNames
Created June 19, 2015 20:34
Extension Method to walk all views in all lists and expand PascalCase view names. E.g. expand "AllItems" to "All Items" in order to keep the %20 chars out of the Url
public static partial class WebExtensions
{
public static void SplitPascalCasedViewNames(this Web web)
{
ListCollection projectLists = web.Lists;
web.Context.Load(projectLists);
web.Context.ExecuteQuery();
foreach (List list in projectLists)
{
ViewCollection listViews = list.Views;
@pkskelly
pkskelly / Send-SendGridMessage.ps1
Created December 2, 2015 20:30
Sending Email from PowerShell using SendGrid (in Azure)
$Username ="azure_*********@azure.com"
$Password = ConvertTo-SecureString "********" -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential $Username, $Password
$SMTPServer = "smtp.sendgrid.net"
$EmailFrom = "admin@acme.com"
$EmailTo = "user@acme.com"
$Subject = "SendGrid test"
$Body = "SendGrid testing successful"
Send-MailMessage -smtpServer $SMTPServer -Credential $credential -Usessl -Port 587 -from $EmailFrom -to $EmailTo -subject $Subject -Body $Body
@pkskelly
pkskelly / createproj.sh
Last active March 27, 2017 12:54
Simple .NET Core CLI set of commands to create a solution with referenced projects on a Mac.
#create the solution
dotnet new sln -n CandidateManager
#create the Console project
dotnet new console --name CandidatesConsole --output CandidatesConsole
#create the web project
dotnet new webapi --name CandidatesWeb --output CandidatesWeb
# These are the templates available from ASP.NET JavaScript Services https://github.com/aspnet/JavaScriptServices
@pkskelly
pkskelly / SMATCollector.ps1
Created July 3, 2017 18:11
Simple Script to combine all SMAT CSV files into a single file
$csvFiles = Get-ChildItem $PSScriptRoot -Include *.csv -Recurse
$fileCount = $csvFiles.Count
Write-Host "Processing files: ($fileCount)"
foreach ($csv in $csvFiles) {
Write-Host "Processing $($csv.BaseName)..."
}
$outputfilename = read-host "Please enter the output file name"
@pkskelly
pkskelly / configureNGStorage.sh
Created December 22, 2017 01:46
Azure CLI script to enable Blob storage containers to serve Angular static files.
#!/bin/bash
AZURE_STORAGE_ACCOUNT=""
AZURE_STORAGE_ACCESS_KEY=""
while getopts "a:k:" opt; do
case $opt in
a)
AZURE_STORAGE_ACCOUNT="${OPTARG}"
;;
@pkskelly
pkskelly / removeNGStorage.sh
Created December 22, 2017 01:51
Azure CLI script to remove Blob storage containers serving Angular static files.
#!/bin/bash
AZURE_STORAGE_ACCOUNT=""
AZURE_STORAGE_ACCESS_KEY=""
while getopts "a:k:" opt; do
case $opt in
a)
AZURE_STORAGE_ACCOUNT="${OPTARG}"
;;
@pkskelly
pkskelly / hubsites.rest
Created May 9, 2018 17:57
Template for HubSite REST Calls. You can copy this file, load the REST Client Extension in VS Code and run the samples. Some configuration and knowledge of OAuth is required.

@host = tenant-name @hubname = hubsite-name @token = Bearer bearer-toekn-value @hubid = hub-id @spokeid = spoke-id @company = your-company

### CanCreate - determine if current user can create a hubsite GET https://{{host}}-admin.sharepoint.com/_api/sp.hubsites.cancreate Accept: application/json

@pkskelly
pkskelly / merge.jq
Last active April 23, 2020 01:57
Merge jq module to merge MS Flow JSON output with Azure AD user information
# Create a dictionary based on the $owner.id property from the owners array parameter
($owners | map(select(.id != null)) | map( {(.id): {displayName, userPrincipalName, mail}}) | add) as $dict
# Output each flow and append the the owner information from each dictionary entry
# using the flow's creator.userId property as the key
| $flows |.[].properties.creator |= . + $dict[.userId]
@pkskelly
pkskelly / generate-flowreport.sh
Last active April 23, 2020 01:56
Bash script using Office 365 CLI and jq to create a csv report of Flow with mapped Owner details
#!/usr/bin/env bash
set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
TMP_ENVIRONMENTS=./tmp/environments.json
TMP_FLOWS=./tmp/flows.json
TMP_OWNERS=./tmp/owners.json
TMP_MAPPEDFLOWS=./tmp/mappedFlows.json
TMP_FLOWSCSV=flows-frombash.csv
@pkskelly
pkskelly / update-ssl-binding.sh
Last active October 20, 2020 12:28
Script to update the SSL certificate for the URL Shortener (or any Azure Web App)
APP_NAME=""
RESOURCE_GROUP=""
CERT_FILE=""
CERT_PASSWORD=""
thumbprint=$(az webapp config ssl upload \
--name $APP_NAME \
--resource-group $RESOURCE_GROUP \
--certificate-file $CERT_FILE \