Last active
May 21, 2025 05:18
-
-
Save Agazoth/d706e2f6b0d1397eeff32a62942a674a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment