Functions/Get-HetznerCloudSshKey.ps1
function Get-HetznerCloudSshKey { [CmdletBinding(DefaultParameterSetName='None')] param( [Parameter(ParameterSetName='ByName')] [ValidateNotNullOrEmpty()] [string] $Name , [Parameter(ParameterSetName='ById')] [ValidateNotNullOrEmpty()] [string] $Id ) if ($PSCmdlet.ParameterSetName -ieq 'ByName') { Get-HetznerCloudSshKey | Where-Object { $_.Name -ieq $Name } } else { Invoke-HetznerCloudApi -Api 'ssh_keys' @PSBoundParameters | ForEach-Object { [pscustomobject]@{ Id = $_.id Name = $_.name Fingerprint = $_.fingerprint PublicKey = $_.public_key PSTypeName = 'HetznerCloudSshKey' } } } } |