Skip to content

Instantly share code, notes, and snippets.

View heaths's full-sized avatar

Heath Stewart heaths

View GitHub Profile
@heaths
heaths / azure-cli.md
Last active May 7, 2025 17:37
Tips and other useful commands for the Azure CLI

Some useful commands for the Azure CLI. Also check out JMESPath specifications for other functions you can use.

Principals

Get the principal OID for a given client ID in a tenant:

# add `--output tsv` to get the raw value without quotes
az ad sp show --id $id --query objectId
@heaths
heaths / main.go
Created February 24, 2021 17:38
Sample for creating an RSA key, wrapping and unwrapping an AES key in Key Vault using Golang
package main
import (
"context"
"fmt"
"os"
"strings"
"net/url"
@heaths
heaths / Program.cs
Last active January 13, 2021 01:16
Example of using EC keys to sign remotely using Key Vault and verify locally
// #r "nuget:Azure.Identity,1.3.0"
// #r "nuget:Azure.Security.KeyVault.Keys,4.1.0"
// #r "nuget:System.CommandLine.DragonFruit,0.3.0-alpha.20574.7"
using System;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using Azure;
using Azure.Identity;
@heaths
heaths / Program.cs
Last active October 23, 2020 17:36
Simple ImportCertificate sample
// Copyright 2020 Heath Stewart
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
//furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
@heaths
heaths / X509Certificate2.psm1
Last active July 15, 2025 15:37
X509Certificate2 PowerShell module
#Requires -Version 6.0
using namespace System.Security.Cryptography
using namespace System.Security.Cryptography.X509Certificates
using namespace System.Text
<#
.Synopsis
Generate an X509 v3 certificate.
@heaths
heaths / Get-AzureKeyVaults.ps1
Last active January 26, 2021 18:56
Gets a list of Key Vaults from the currently selected subscription
$vaults = az resource list --resource-type Microsoft.KeyVault/vaults | convertfrom-json
$managedHsms = az resource list --resource-type Microsoft.KeyVault/managedHSMs | convertfrom-json
$lookup = $vaults + $managedHsms | group id -asstring -ashashtable
function get-delta ($dt) {
if ($dt -ge [datetime]::now.adddays(-1)) {
'<= 1d'
} elseif ($dt -ge [datetime]::now.adddays(-7)) {
'<= 7d'
} elseif ($dt -ge [datetime]::now.adddays(-30)) {
@heaths
heaths / Copy-SpotlightImages.ps1
Last active August 2, 2022 01:12
Copies JPG and PNG images from the Content Delivery Manager.
#Requires -Version 5.1
#Requires -Modules 'Appx'
[CmdletBinding()]
param (
[Parameter(Mandatory=$true, Position=0)]
[string] $Destination,
[Parameter()]
[ValidateNotNullOrEmpty()]
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.2.1" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.1.0" />
@heaths
heaths / prompt
Last active June 2, 2024 00:34
Value of my PROMPT environment variables across machines
$E[0;38;5;231;48;5;31m$M$E[38;5;31;48;5;240m$S$E[38;5;231m$P$S$E[0;38;5;240m$E[0m$_$E[38;5;231;48;5;240m$+$E[0;38;5;240m$E[0m$S
@heaths
heaths / settings.json
Last active June 2, 2024 00:34
Settings for Windows Terminal
{
"$help": "https://aka.ms/terminal-documentation",
"$schema": "https://aka.ms/terminal-profiles-schema",
"actions":
[
{
"command": "closePane",
"keys": "ctrl+alt+w"
},
{