Skip to content

Instantly share code, notes, and snippets.

View JeffMill's full-sized avatar

Jeff Miller JeffMill

  • Microsoft
  • Redmond, WA
View GitHub Profile
@JeffMill
JeffMill / Dump-Signers.ps1
Last active September 20, 2024 20:41
Dump certs in a binary
Param([Parameter(Mandatory)][string]$Path)
# Caveats:
#
# Get-AuthenticodeSignature cmdlet has the following limitations:
# * Only first signature is fetched;
# * If the signature is timestamped, no signing time is provided;
# * No signature algorithm information is provided.
$chain = New-Object -TypeName Security.Cryptography.X509Certificates.X509Chain
@JeffMill
JeffMill / Remove-Old-Az-Modules.ps1
Last active March 25, 2025 18:57
Remove older PowerShell Az modules
# Note: This doesn't always work correctly.
# might get: Uninstall-Package: No match was found for the specified search criteria and module names...
# Can remove all az.* packages (and then manually reinstall) using:
# $env:PSModulePath -split ';' | ForEach-Object { Get-ChildItem -Directory -Path (Join-Path $_ 'Az.*') | ForEach-Object { Remove-Item -LiteralPath $_.FullName -Recurse -Verbose -Force } }
# (Which could also be updated to remove just older versions in each folder)
foreach ($module in (Get-Module -ListAvailable -Name 'Az*').Name | Get-Unique) {
$modules = Get-Module -ListAvailable $module
if ($modules.Count -gt 1) {
@JeffMill
JeffMill / gitgrepblame.ps1
Last active April 22, 2025 17:30
gitgrepblame: Combination of "git grep" and "git blame".
<#
.SYNOPSIS
Combination of "git grep" and "git blame".
#>
function gitgrepblame {
Param([Parameter(Mandatory)][string]$Query)
# grep "--null" uses null separators, blame "-c" uses tab separators.
git.exe --no-pager grep --null --line-number $Query `
| Select-String -Pattern '(?<Filename>[^\0]+)\0(?<Line>[1-9][0-9]*)\0\s*(?<Text>.+)' `
@JeffMill
JeffMill / pipe-powershell.cs
Last active April 22, 2025 23:07
Pipe powershell command output to C# program
using System.Diagnostics;
using System.Text;
using (Process process = new Process())
{
int timeoutMS = 1000;
process.StartInfo.FileName = "powershell.exe";
process.StartInfo.Arguments = "-NoLogo -NoProfile -NonInteractive -Command \"&{ Get-DeliveryOptimizationLog }\"";
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
@JeffMill
JeffMill / mermaid-class-diagram-refrerence.md
Last active October 8, 2025 22:05
Mermaid Class Diagram Reference

Mermaid Class Diagram Reference

Adapted from Class diagrams

Type: classdiagram

Visibility

e.g. -idCard : IdCard