curt.psm1
|
<# .SYNOPSIS Interactive certificate picker using certutil + gawk + fzf. .DESCRIPTION Wraps certutil -store through gawk for parsing and fzf for multi-select. Outputs serial numbers of selected certificates. .EXAMPLE # Browse current user My store curt # Browse LocalMachine My store (requires admin) curt -Store Lm # Delete selected certs curt | ForEach-Object { certutil -delstore My $_ } # Delete from machine store curt -Store Lm | ForEach-Object { certutil -delstore -enterprise My $_ } #> function Invoke-Curt { [CmdletBinding()] [Alias('curt')] param( [Parameter()] [ValidateSet('My', 'Lm')] [string]$Store = 'My' ) $certutilArgs = if ($Store -eq 'Lm') { @('-store', '-enterprise', 'My') } else { @('-store', 'My') } certutil @certutilArgs | gawk 'BEGIN { RS="={10,}"; FPAT="[^:^\n]+:[^\n]+"; OFS="\t" } NF>1 { $1=$1; print }' | fzf -m | gawk '{ gsub("\t", "\n", $0); print }' | gawk 'BEGIN { FPAT="Serial Number:[^\n]+"; } NF>0 { gsub("Serial Number: ","", $1); print }' } Export-ModuleMember -Function Invoke-Curt -Alias curt |