mirror of
https://github.com/Corsinvest/cv4pve-api-powershell.git
synced 2026-04-25 12:15:48 +03:00
[GH-ISSUE #28] change use of PSBoundParameters in New-PveNodesQemuConfig and Set-PveNodesQemuConfig to better support passing variables with value of false #20
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/cv4pve-api-powershell#20
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @acac9 on GitHub (Jan 26, 2025).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/28
What happened?
New-PveNodesQemuConfig and Set-PveNodesQemuConfig use the statement
if($PSBoundParameters['Template']) and many similar lines.
Take for an example case that we are calling one of these functions and we are passing that -Template:$false because we want to turn a template into a VM.
We reach the line:
if($PSBoundParameters['Template']) { $parameters['template'] = $Template }
and it evaluates to $false in the if statement, causing the { $parameters['template'] = $Template } to not be executed.
That means the information is not sent in the API call and the template is never turned into a VM.
This can be fixed by changing:
if($PSBoundParameters['Template'])
to:
if($PSBoundParameters.ContainsKey('Template'))
Expected behavior
In this specific case, calling Set-PveNodesQemuConfig with -Template:$false when the target is a template, would turn the existing template into a VM. There may be other use cases as well where we want to pass a parameter that equals $false but I am not sure of all the use cases.
Relevant log output
Proxmox VE Version
8.3.0
Version (bug)
8.3.0
Version (working)
No response
On what operating system are you experiencing the issue?
Windows
Pull Request
sudopermissions #36