using System; using System.Management.Automation; using PSProxmox.Client; using PSProxmox.Session; namespace PSProxmox.Cmdlets { /// /// Removes an SDN zone from Proxmox VE. /// The Remove-ProxmoxSDNZone cmdlet removes an SDN zone from Proxmox VE. /// /// Remove an SDN zone /// Remove-ProxmoxSDNZone -Connection $connection -Zone "zone1" /// /// /// Remove an SDN zone using pipeline input /// Get-ProxmoxSDNZone -Connection $connection -Zone "zone1" | Remove-ProxmoxSDNZone -Connection $connection /// /// [Cmdlet(VerbsCommon.Remove, "ProxmoxSDNZone", SupportsShouldProcess = true, ConfirmImpact = ConfirmImpact.High)] public class RemoveProxmoxSDNZoneCmdlet : PSCmdlet { /// /// The connection to the Proxmox VE server. /// [Parameter(Mandatory = true, Position = 0)] public ProxmoxConnection Connection { get; set; } /// /// The name of the zone to remove. /// [Parameter(Mandatory = true, ValueFromPipelineByPropertyName = true)] public string Zone { get; set; } /// /// Processes the cmdlet. /// protected override void ProcessRecord() { try { var client = new ProxmoxApiClient(Connection, this); // Confirm removal if (!ShouldProcess($"SDN zone {Zone}", "Remove")) { return; } // Remove the zone WriteVerbose($"Removing SDN zone {Zone}"); client.Delete($"sdn/zones/{Zone}"); WriteVerbose($"SDN zone {Zone} removed"); } catch (Exception ex) { WriteError(new ErrorRecord(ex, "RemoveProxmoxSDNZoneError", ErrorCategory.OperationStopped, Zone)); } } } }