[GH-ISSUE #28] change use of PSBoundParameters in New-PveNodesQemuConfig and Set-PveNodesQemuConfig to better support passing variables with value of false #20

Closed
opened 2026-02-26 17:32:09 +03:00 by kerem · 0 comments
Owner

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

  • I would like to do a Pull Request
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 ```shell ``` ### 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 - [ ] I would like to do a Pull Request
kerem closed this issue 2026-02-26 17:32:10 +03:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/cv4pve-api-powershell#20
No description provided.