Functions/Remove-HetznerCloudServer.ps1
function Remove-HetznerCloudServer { [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 server with ID <$_>" if ($Force -or $PSCmdlet.ShouldProcess("Remove server with ID <$Id>?")) { Invoke-HetznerCloudApi -Api 'servers' -Id $_ -Method 'Delete' } } } } |