Functions/Restore-HetznerCloudServer.ps1
function Restore-HetznerCloudServer { [CmdletBinding(SupportsShouldProcess, ConfirmImpact='High')] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [int] $Id , [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [int] $Image ) begin { if (-not $PSBoundParameters.ContainsKey('Confirm')) { $ConfirmPreference = $PSCmdlet.SessionState.PSVariable.GetValue('ConfirmPreference') } if (-not $PSBoundParameters.ContainsKey('WhatIf')) { $WhatIfPreference = $PSCmdlet.SessionState.PSVariable.GetValue('WhatIfPreference') } } process { if ($Force -or $PSCmdlet.ShouldProcess("Restore server with ID <$Id> from image with ID <$Image>?")) { Invoke-HetznerCloudApi -Api 'servers' -Id $Id -Action 'rebuild' -Method 'Post' -Payload @{ image = $Image } } } } |