fix: backup job creation requires vmid or -All, fix Enabled default

- Integration test: add -All to New-PveBackupJob call — PVE API
  requires either vmid or all when creating a backup job
- Fix New-PveBackupJob Enabled logic: jobs are enabled by default
  unless user explicitly passes -Enabled:$false (was broken because
  SwitchParameter default=true doesn't set IsPresent)
- Fix XML doc cref warning in NetworkService after RequireSdn removal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Clint Branham
2026-03-21 09:07:39 -05:00
parent b11f41a5cc
commit 4b503b08db
3 changed files with 6 additions and 6 deletions
@@ -11,7 +11,7 @@ namespace PSProxmoxVE.Core.Services
{
/// <summary>
/// Service for Proxmox VE node network and SDN (Software-Defined Networking) API operations.
/// SDN methods require PVE 8.0 or later and will throw <see cref="PveVersionException"/> otherwise.
/// SDN methods require PVE 8.0 or later. Version checks are performed at the cmdlet layer.
/// </summary>
public class NetworkService
{
@@ -73,10 +73,10 @@ namespace PSProxmoxVE.Cmdlets.Backup
public string? MailNotification { get; set; }
/// <summary>
/// <para type="description">Whether the backup job is enabled. Default is true.</para>
/// <para type="description">Whether the backup job is enabled. Enabled by default unless -Enabled:$false is specified.</para>
/// </summary>
[Parameter(Mandatory = false, HelpMessage = "Whether the backup job is enabled.")]
public SwitchParameter Enabled { get; set; } = true;
[Parameter(Mandatory = false, HelpMessage = "Whether the backup job is enabled. Default is enabled.")]
public SwitchParameter Enabled { get; set; }
/// <summary>
/// <para type="description">A comment or description for the backup job.</para>
@@ -102,7 +102,7 @@ namespace PSProxmoxVE.Cmdlets.Backup
{
["schedule"] = Schedule,
["storage"] = Storage,
["enabled"] = Enabled.IsPresent ? "1" : "0"
["enabled"] = MyInvocation.BoundParameters.ContainsKey("Enabled") && !Enabled.IsPresent ? "0" : "1"
};
if (!string.IsNullOrEmpty(Mode)) config["mode"] = Mode!;
@@ -1443,7 +1443,7 @@ Describe 'Integration Tests' -Tag 'Integration' {
Context 'Backup Jobs' {
It 'Should create a backup job' {
Skip-IfNoTarget
{ New-PveBackupJob -Schedule 'sat 03:00' -Storage $script:Storage -Mode snapshot -Comment 'pester-test-backup' -ErrorAction Stop } | Should -Not -Throw
{ New-PveBackupJob -Schedule 'sat 03:00' -Storage $script:Storage -Mode snapshot -All -Comment 'pester-test-backup' -ErrorAction Stop } | Should -Not -Throw
}
It 'Should list backup jobs and find the test job' {