Skip to content

Instantly share code, notes, and snippets.

# Get the Job ID from PSPrivateMetadata. That's the only thing it contains!
$automationJobId = $PSPrivateMetadata.JobId.Guid
# Maximum number of instances of this Runbook I want running at any given time
$numberOfInstances = 1
# Connect to Azure. With a Managed Identity in this case as that's what I use.
# Must connect to Azure before running Get-AzAutomationJob or Get-AzResource
try {
# From https://docs.microsoft.com/en-us/azure/automation/enable-managed-identity-for-automation#authenticate-access-with-system-assigned-managed-identity
@rakheshster
rakheshster / createmacvlan.sh
Created August 24, 2020 14:55
This is just a script for me to quickly create a macvlan network.
#!/bin/bash
# Usage ./createmacvlan.sh <subnet> <gateway> <interface> [network name]
# This is just a script for me to quickly create a macvlan network.
# if the first or second arguments are missing give a usage message and exit
if [[ -z "$1" || -z "$2" || -z "$3" ]]; then
echo "Usage ./createmacvlan.sh <subnet> <gateway> <interface> [network name]"
exit 1
else
@rakheshster
rakheshster / dockervolbkp.sh
Last active August 25, 2020 13:56
Backup the Docker volumes of all running containers. This requires 'jq'. Currently it uses some Bashisms but can be easily changes for others shells I imagine.
#!/bin/bash
BACKUPFOLDER="/opt/backups"
TIMESTAMP=$(date '+%Y-%m-%d')
if ! command -v jq &> /dev/null; then echo "Cannot find jq. Exiting ..."; exit 1; fi
# Get list of running containers
CONTAINERS=( $(docker ps --format '{{.Names}}') )
@rakheshster
rakheshster / Get-Parameters.ps1
Last active June 2, 2020 20:00
Get parameters of a PowerShell Cmdlet
function Get-Parameters {
param ($cmdlet)
if (Get-Command $cmdlet -ErrorAction SilentlyContinue) {
Get-Help -Name $cmdlet -Full | Select-Object -expandProperty Parameters | Select-Object -ExpandProperty Parameter | select -Property Name,PipelineInput
} else {
Write-Error "$cmdlet not found" -ErrorAction Stop
}
}
@rakheshster
rakheshster / settings.json
Created May 13, 2019 14:18
Dracula Theme Colors for Visual Studio Code terminal
"workbench.colorCustomizations":{
"terminal.foreground": "#f8f8f2",
"terminal.background": "#282a36",
"terminal.ansiBlack": "#003541",
"terminal.ansiBlue": "#268bd2",
"terminal.ansiCyan": "#8be9fd",
"terminal.ansiGreen": "#50fa7b",
"terminal.ansiMagenta": "#ff79c6",
"terminal.ansiRed": "#ff5555",
"terminal.ansiWhite": "#eee8d5",