Raw API
From endpoint to cmdlet
Section titled “From endpoint to cmdlet”The generated cmdlets are built from the Proxmox VE API, one per endpoint and HTTP method. Knowing the rule, you can go from what you see in the API viewer to the cmdlet name without searching:
- Verb from the HTTP method:
GET→Get,PUT→Set,POST→New,DELETE→Remove. - Noun:
Pvefollowed by the segments of the path, each capitalized, leaving out the{parameters}and dropping-and_. - When two endpoints would get the same name (a list and one of its items), the second gets
Idx, and a number if needed.
| Endpoint | Cmdlet |
|---|---|
GET /nodes/{node}/qemu |
Get-PveNodesQemu |
GET /nodes/{node}/qemu/{vmid}/config |
Get-PveNodesQemuConfig |
PUT /nodes/{node}/qemu/{vmid}/config |
Set-PveNodesQemuConfig |
POST /nodes/{node}/qemu/{vmid}/status/start |
New-PveNodesQemuStatusStart |
DELETE /nodes/{node}/qemu/{vmid}/snapshot/{snapname} |
Remove-PveNodesQemuSnapshot |
GET /cluster/replication |
Get-PveClusterReplication |
GET /cluster/replication/{id} |
Get-PveClusterReplicationIdx |
The path parameters become mandatory parameters of the cmdlet: -Node, -Vmid, -Snapname. Actions
are POST, so they start with New- even when nothing is created: New-PveNodesQemuStatusStart starts
a VM. For the most common ones the module has shorter aliases,
such as Start-PveQemu.
Every page of the cmdlet reference shows its endpoint, and every group page lists them side by side.
Invoke-PveRestApi
Section titled “Invoke-PveRestApi”All cmdlets end in Invoke-PveRestApi, which you can call yourself, for an endpoint added by a newer
Proxmox VE than your version of the module, or to build a path in a loop:
$r = Invoke-PveRestApi -Method Get -Resource '/nodes/pve01/status'$r.Response.data.cpuinfo| Parameter | |
|---|---|
-Resource |
The API path, starting with /, without /api2/json: /nodes/pve01/status. |
-Method |
Get (default), Set (PUT), Create (POST), Delete (DELETE). |
-Parameters |
A hashtable with the API parameter names: @{ vmstate = 1; snapname = 'before-update' }. For Get and Delete they go in the query string, for Set and Create in a JSON body. [bool] and switch values are sent as 1 and 0. |
-ResponseType |
json (default), extjs, html, text, png. |
-PveTicket |
The connection; without it, the last one: see Connection. |
It returns a PveResponse, like the generated cmdlets, and does not throw when the call fails: see
Results and Errors.
# snapshot every VM of a node, building the path yourselfforeach ($vm in (Get-PveNodesQemu -Node pve01).Response.data) { Invoke-PveRestApi -Method Create -Resource "/nodes/pve01/qemu/$($vm.vmid)/snapshot" ` -Parameters @{ snapname = 'before-update' }}