Skip to content

Repository files navigation

cv4pve-api-powershell

     ______                _                      __
    / ____/___  __________(_)___ _   _____  _____/ /_
   / /   / __ \/ ___/ ___/ / __ \ | / / _ \/ ___/ __/
  / /___/ /_/ / /  (__  ) / / / / |/ /  __(__  ) /_
  \____/\____/_/  /____/_/_/ /_/|___/\___/____/\__/

PowerShell for Proxmox VE (Made in Italy)

License PowerShell Gallery Downloads

The PowerCLI for Proxmox VE: a PowerShell module with a cmdlet for every endpoint of the Proxmox VE API, running on your machine and talking only to the API.

Documentation


PowerShell holding a shield with the Proxmox logo

Why

The Proxmox VE web interface is made for one action at a time. Snapshot forty VMs before an update, list every VM with its disks for an audit, clone a template ten times, shut down a lab every evening: by hand it is slow and error-prone.

VMware administrators have PowerCLI for this. cv4pve-api-powershell is the same idea for Proxmox VE: the whole API as PowerShell cmdlets, so your scripts, scheduled tasks and habits keep working: objects in the pipeline, Where-Object, Export-Csv, Get-Help.

It runs on your machine and uses only the Proxmox VE API: nothing to install on the nodes, no SSH.


Features

  • The whole API: one cmdlet per endpoint and method, generated from the Proxmox VE API, with its parameters, types and allowed values.
  • VMs by id or name: Get-PveGuest finds VMs and containers by id, name, range, node, pool or tag, with exclusions; the same selection starts, stops or snapshots them all in one call.
  • API token or password: list several nodes and the first that answers is used.
  • Objects, not text: the Proxmox VE data as PowerShell objects, with the HTTP outcome beside it.
  • Tasks: start a backup, clone or migration and wait for it to finish, with a progress bar if you like.
  • Anything else: Invoke-PveRestApi calls any path of the API with the same connection.
  • -WhatIf and -Confirm: on every cmdlet that changes something, to see what would be done before doing it; without them nothing asks, as scripts expect.
  • Cross-platform: PowerShell 7 on Windows, Linux and macOS.

Quick start

Install-Module -Name Corsinvest.ProxmoxVE.Api -Scope CurrentUser

# connect to any node of the cluster, with an API token
Connect-PveCluster -HostsAndPorts pve01 -ApiToken 'automation@pve!ps=<secret>'

# every VM and container of the cluster
Get-PveGuest | Format-Table vmid, name, node, type, status

# the generated cmdlets return the data in .Response.data
(Get-PveNodesQemuConfig -Node pve01 -Vmid 100).Response.data

Requires PowerShell 7. With a self-signed certificate add -SkipCertificateCheck. What the token needs: Permissions.


What it looks like

PS> Get-PveGuest | Format-Table vmid, name, node, type, status

vmid name        node  type status
---- ----        ----  ---- ------
 105 test        pve01 lxc  stopped
1006 dc01        pve01 qemu running
 100 backup01    pve02 lxc  running
 102 firewall02  pve02 qemu running
1012 mailstore   pve02 qemu running

PS> Get-PveNode | Select-Object node, status, @{ n = 'cpu%'; e = { [math]::Round($_.cpu * 100, 1) } }

node  status cpu%
----  ------ ----
pve02 online 1.50
pve01 online 4.20

Get-PveGuest returns the guests themselves; the generated cmdlets return a PveResponse with the data in .Response.data. More recipes, each with its output: Common tasks.


Documentation

Getting started Install, connect, first cmdlets
Connection API token or password, several nodes, certificates, permissions
Coming from PowerCLI Each PowerCLI cmdlet mapped to its equivalent, and what works differently
Concepts Results, parameters, tasks, errors, raw API calls
Guides VMs by id or name, power, snapshots, SPICE
Examples Common tasks with their output, inventory to CSV, creating VMs, guest agent, backups
Cmdlet reference Every cmdlet with its endpoint and parameters
AI assistants Claude Code, Codex, the cv4pve-api-powershell skill
Troubleshooting -Debug and the common errors

Related tools

Prefer the command line in any shell? cv4pve-cli calls the same API. From .NET: cv4pve-api-dotnet. The whole suite: corsinvest.it/cv4pve.


Support

Professional support and consulting available through Corsinvest.


By sysadmins, for sysadmins.

Part of cv4pve suite | Made with ❤️ in Italy by Corsinvest

Proxmox® is a registered trademark of Proxmox Server Solutions GmbH. cv4pve is developed by Corsinvest and is not a Proxmox product.

Copyright © Corsinvest Srl