[GH-ISSUE #45] Unlock-PveVm does not work because of pipelined VM Data #28

Closed
opened 2026-02-26 17:32:13 +03:00 by kerem · 1 comment
Owner

Originally created by @r3st0r3 on GitHub (Dec 19, 2025).
Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/45

What happened?

The function Unlock-PveVm does not work. Executing with a locked vm (example ID 115) returns an error.

To reproduce lock the vm manually via SSH: qm set 115 --lock create

Then after connection to your cluster run:
Unlock-PveVm -PveTicket $myCluster -VmIdOrName 115

Response :
StatusCode : 400
ReasonPhrase : Parameter verification failed.
IsSuccessStatusCode : False
RequestResource : /nodes/xpve17/qemu/115/config
Parameters : {[delete, lock], [skiplock, True], [lock, create], [name, VM 115]…}
Method : Put
ResponseType : json

Details of Parameters of Return (parameters that the api received from my side)

Name Value


delete lock
skiplock True
lock create
name VM 115
cpu 0
template False

I wondered some time where the values lock, cpu and template come from as the call of Set-PveNodesQemuConfig does not set them (process part of Unlock-PveVm):

process {
        $vm = Get-PveVm -PveTicket $PveTicket -VmIdOrName $VmIdOrName
        if ($vm.type -eq 'qemu') { return $vm | **Set-PveNodesQemuConfig -PveTicket $PveTicket -Delete 'lock' -Skiplock** }
        ElseIf ($vm.type -eq 'lxc') { return $vm | Set-PveNodesLxcConfig -PveTicket $PveTicket -Delete 'lock' }
    }

They come from the Pipelining of $vm! For example my variable $vm looks like

mem : 0
template : 0
netout : 0
uptime : 0
diskwrite : 0
memhost : 0
id : qemu/115
vmid : 115
name : VM 115
lock : create
status : stopped
maxdisk : 0
netin : 0
cpu : 0
diskread : 0
maxcpu : 1
maxmem : 536870912
disk : 0
node : xpve17
type : qemu

To fix please change the process part of the function to

process {
        $vm = Get-PveVm -PveTicket $PveTicket -VmIdOrName $VmIdOrName
        if ($vm.type -eq 'qemu') { return Set-PveNodesQemuConfig -PveTicket $PveTicket -node $vm.node -Vmid $vm.vmid -Delete 'lock' -Skiplock:$true }
        ElseIf ($vm.type -eq 'lxc') { return $vm | Set-PveNodesLxcConfig -PveTicket $PveTicket -Delete 'lock' }
    }

This will prevent the takeover of values from the vm-variable from the line before.

Unfortunately I do not have an lxc to test. I think this line also needs to be changed to not be filled with pipeline-values.

Expected behavior

Response : @{data=}
StatusCode : 200
ReasonPhrase :
IsSuccessStatusCode : True
RequestResource : /nodes/xpve17/qemu/115/config
Parameters : {[skiplock, True], [delete, lock]}
Method : Put
ResponseType : json

Relevant log output

Response            :
StatusCode          : 400
ReasonPhrase        : Parameter verification failed.
IsSuccessStatusCode : False
RequestResource     : /nodes/xpve17/qemu/115/config
Parameters          : {[delete, lock], [skiplock, True], [lock, create], [name, VM 115]}
Method              : Put
ResponseType        : json

Proxmox VE Version

9.1

Module Version

9.1.0

PowerShell Version

7.4.13

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 @r3st0r3 on GitHub (Dec 19, 2025). Original GitHub issue: https://github.com/Corsinvest/cv4pve-api-powershell/issues/45 ### What happened? The function Unlock-PveVm does not work. Executing with a locked vm (example ID 115) returns an error. To reproduce lock the vm manually via SSH: `qm set 115 --lock create` Then after connection to your cluster run: `Unlock-PveVm -PveTicket $myCluster -VmIdOrName 115` > Response : > StatusCode : 400 > ReasonPhrase : Parameter verification failed. > IsSuccessStatusCode : False > RequestResource : /nodes/xpve17/qemu/115/config > Parameters : {[delete, lock], [skiplock, True], [lock, create], [name, VM 115]…} > Method : Put > ResponseType : json Details of Parameters of Return (parameters that the api received from my side) > Name Value > ---- ----- > delete lock > skiplock True > **lock create** > name VM 115 > **cpu 0** > **template False** I wondered some time where the values _lock, cpu and template_ come from as the call of Set-PveNodesQemuConfig does not set them (process part of Unlock-PveVm): ``` process { $vm = Get-PveVm -PveTicket $PveTicket -VmIdOrName $VmIdOrName if ($vm.type -eq 'qemu') { return $vm | **Set-PveNodesQemuConfig -PveTicket $PveTicket -Delete 'lock' -Skiplock** } ElseIf ($vm.type -eq 'lxc') { return $vm | Set-PveNodesLxcConfig -PveTicket $PveTicket -Delete 'lock' } } ``` They come from the Pipelining of $vm! For example my variable $vm looks like > mem : 0 > **template : 0** > netout : 0 > uptime : 0 > diskwrite : 0 > memhost : 0 > id : qemu/115 > vmid : 115 > name : VM 115 > **lock : create** > status : stopped > maxdisk : 0 > netin : 0 > **cpu : 0** > diskread : 0 > maxcpu : 1 > maxmem : 536870912 > disk : 0 > node : xpve17 > type : qemu To fix please change the process part of the function to ``` process { $vm = Get-PveVm -PveTicket $PveTicket -VmIdOrName $VmIdOrName if ($vm.type -eq 'qemu') { return Set-PveNodesQemuConfig -PveTicket $PveTicket -node $vm.node -Vmid $vm.vmid -Delete 'lock' -Skiplock:$true } ElseIf ($vm.type -eq 'lxc') { return $vm | Set-PveNodesLxcConfig -PveTicket $PveTicket -Delete 'lock' } } ``` This will prevent the takeover of values from the vm-variable from the line before. Unfortunately I do not have an lxc to test. I think this line also needs to be changed to not be filled with pipeline-values. ### Expected behavior Response : @{data=} StatusCode : 200 ReasonPhrase : IsSuccessStatusCode : True RequestResource : /nodes/xpve17/qemu/115/config Parameters : {[skiplock, True], [delete, lock]} Method : Put ResponseType : json ### Relevant log output ```shell Response : StatusCode : 400 ReasonPhrase : Parameter verification failed. IsSuccessStatusCode : False RequestResource : /nodes/xpve17/qemu/115/config Parameters : {[delete, lock], [skiplock, True], [lock, create], [name, VM 115]…} Method : Put ResponseType : json ``` ### Proxmox VE Version 9.1 ### Module Version 9.1.0 ### PowerShell Version 7.4.13 ### Version (working) _No response_ ### On what operating system are you experiencing the issue? Windows ### Pull Request - [x] I would like to do a Pull Request
kerem closed this issue 2026-02-26 17:32:13 +03:00
Author
Owner

@r3st0r3 commented on GitHub (Dec 19, 2025):

Please note also: I corrected the usage of the boolean parameter -Skiplock to -Skiplock:$true because of the error message:

Missing an argument for parameter 'Skiplock'. Specify a parameter of type 'System.Boolean' and try again

<!-- gh-comment-id:3675168432 --> @r3st0r3 commented on GitHub (Dec 19, 2025): Please note also: I corrected the usage of the boolean parameter -Skiplock to -Skiplock:$true because of the error message: > Missing an argument for parameter 'Skiplock'. Specify a parameter of type 'System.Boolean' and try again
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#28
No description provided.