Public/Get-SshImportIdSource.ps1
|
function Get-SshImportIdSource { <# .SYNOPSIS Lists known ssh-import-id source prefixes (built-in and custom). .PARAMETER Prefix Optionally filter to a specific prefix. .EXAMPLE Get-SshImportIdSource Lists gh, gl, lp and any registered custom prefixes. #> [CmdletBinding()] [OutputType([pscustomobject])] param( [Parameter(Position = 0)] [string] $Prefix ) $builtIn = [ordered]@{ gh = 'https://github.com/{0}.keys' gl = 'https://gitlab.com/{0}.keys' lp = 'https://launchpad.net/~{0}/+sshkeys' } $custom = Get-SshImportIdCustomSourceMap $all = [ordered]@{} foreach ($key in $builtIn.Keys) { $all[$key] = [pscustomobject]@{ Prefix = $key; UrlTemplate = $builtIn[$key]; Type = 'Built-in' } } foreach ($key in $custom.Keys) { $all[$key] = [pscustomobject]@{ Prefix = $key; UrlTemplate = $custom[$key]; Type = 'Custom' } } if ($Prefix) { $all[$Prefix.ToLowerInvariant()] } else { $all.Values } } |