Skip to content

Instantly share code, notes, and snippets.

View pkskelly's full-sized avatar

Pete Skelly pkskelly

View GitHub Profile
@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 / ToCSV.cs
Created April 14, 2015 19:40
Simple (Very) C# Extension Method for conversion to a CSV list
public static string ToCsv<T>(string separator, IEnumerable<T> objectlist)
{
Type t = typeof(T);
FieldInfo[] fields = t.GetFields();
string header = String.Join(separator, fields.Select(f => f.Name).ToArray());
StringBuilder csvdata = new StringBuilder();
csvdata.AppendLine(header);
@pkskelly
pkskelly / Get-GuestUsers.ps1
Created December 20, 2021 19:23
The Get-GuestUsers.ps1 script inventories Guest accounts and Sign In Activity from Azure AD into a SharePoint Online List.
#!/usr/local/bin/pwsh -File
<#
.SYNOPSIS
The Get-GuestUsers.ps1 script inventories Guest accounts and Sign In Activity from Azure AD into a SharePoint Online List.
.DESCRIPTION
The Get-GuestUsers.ps1 script inventories Guest accounts from Active Directory using the CLI for M365
and PowerShell's Invoke-RestMethod to query Microsoft Graph for a all Guest accounts and signInActivity.
The script can also gather Teams that the Guest account is a member of by inclusing the -InlcudeTeams switch.
@pkskelly
pkskelly / TW-CreateBlankClientExtranetSite.ps1
Created December 3, 2014 20:06
Add a blank site collection to an Office 365 tenant in SharePoint Online
# =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
# Script: TW-CreateBlankClientExtranetSite.ps1
#
# Author: Pete Skelly
# Twitter: ThreeWillLabs
# http://www.threewill.com
#
# Description: Add a blank site collection to an Office 365 tenant in SharePoint Online
#
# WARNING: Script provided AS IS with no warranty. Your mileage will vary. Use
@pkskelly
pkskelly / Get-FlowOwners.ps1
Last active March 1, 2021 19:39
PowerShell Core script that retrieves and exports Flows and Owner information to CSV file
#!/usr/local/bin/pwsh -File
$DIR = Split-Path $script:MyInvocation.MyCommand.Path
$TMP_DIR = "./tmp"
$FLOWSCSV_SUFFIX = "-flows.csv"
$ALLFLOWSCSV = "allflows.csv"
function CleanDistFolder {
# Remove the dist folder as needed
if (Test-Path -Path "$TMP_DIR" -PathType Container) {
@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 \
@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 / VSCodeTerminalKeybindings.json
Last active January 27, 2020 20:27
VS Code Terminal Keybindings to enable Ctrl+` to switch back to the editor and Shift+Cmd+] to move between active terminal sessions. Press cmd+shift+p and type keyboard to find Preferences: Open Keyboard Shortcuts File. Add the following to the keybindings.json or update the existing file and save it.
// Place your key bindings in this file to override the defaults
[
// Toggle to terminal focus
{
"key": "ctrl+`",
"command": "workbench.action.terminal.focus"
},
// Toggle to editor focus
{
"key": "ctrl+`",
@pkskelly
pkskelly / teamify-classicsite.sh
Last active August 13, 2019 20:47
Shell script using Office 365 CLI v2 to group enable and connect a MS Team to an existing SharePoint Online classic team site.
#!/usr/bin/env bash
help() {
echo
echo " ****************************************************************"
echo " ** Teamify Classic Site "
echo " ** "
echo " ** Simple script to Groupify and Teamify a SharePoint Online Classic site"
echo " ** "
echo " ** Usage: ./teamify-classicsite.sh -s|--siteUrl [classic site url] -a|--alias [alias] -d|--description [description]"