Skip to content

Instantly share code, notes, and snippets.

@Agazoth
Last active December 10, 2025 09:54
Show Gist options
  • Select an option

  • Save Agazoth/d706e2f6b0d1397eeff32a62942a674a to your computer and use it in GitHub Desktop.

Select an option

Save Agazoth/d706e2f6b0d1397eeff32a62942a674a to your computer and use it in GitHub Desktop.
Import-Module posh-git
$GitPromptSettings.DefaultPromptBeforeSuffix.Text = '`nPS'
function Get-Access { Get-AzContext -ListAvailable | Sort-Object account | Out-ConsoleGridView | Set-AzContext }
function Get-Subscription { Get-AzSubscription | Sort-Object Name | Out-ConsoleGridView | Select-AzSubscription }
Import-Module PSReadLine
Set-PSReadLineOption -PredictionSource History
function _ {
param (
[parameter(Mandatory)]
[string[]]$Strings
)
$Strings
}
Class UserSecretsId : System.Management.Automation.IValidateSetValuesGenerator
{
[string[]] GetValidValues() {
[System.IO.DirectoryInfo]$secretsPath = "$($env:APPDATA)\Microsoft\UserSecrets"
$UserSecretsId = $secretsPath.Exists ? $secretsPath.GetDirectories().Name : @()
return [string[]]$UserSecretsId
}
}
function Get-UserSecrets {
param (
[parameter(Mandatory)]
[ValidateSet([UserSecretsId])]
[string]$UserSecretsId,
[switch]$OpenInCode
)
[System.IO.FileInfo]$path = "$($env:APPDATA)\Microsoft\UserSecrets\$UserSecretsId\secrets.json"
if (!$path.Exists) {
Write-Warning "User secrets file not found at path: $path"
return
}
if ($OpenInCode) {
code $path.FullName
return
}
$json = Get-Content -Path $path -Raw | ConvertFrom-Json
return $json
}
function Decode-JwtPayload {
param ([string]$jwt)
$parts = $jwt -split '\.'
if ($parts.Length -lt 2) { Write-Error "Invalid JWT format"; return }
$payload = $parts[1] + '=' * ((4 - $parts[1].Length % 4) % 4)
$decoded = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($payload))
return $decoded | ConvertFrom-Json
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment