Functions/Remove-HetznerCloudSshKey.ps1
function Remove-HetznerCloudSshKey { [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')] param( [Parameter(Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] [ValidateNotNullOrEmpty()] [int[]] $Id ) begin { if (-not $PSBoundParameters.ContainsKey('Confirm')) { $ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference') } if (-not $PSBoundParameters.ContainsKey('WhatIf')) { $WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference') } } process { $Id | ForEach-Object { Write-Verbose "Removing SSH public key with ID <$_>" if ($Force -or $PSCmdlet.ShouldProcess("Remove SSH public key with ID <$Id>?")) { Invoke-HetznerCloudApi -Api 'ssh_keys' -Method 'Delete' -Id $_ } } } } |