Skip to content

PowerCLI for Proxmox VE: the command equivalents

If you automated vSphere with PowerCLI, this module is the same idea for Proxmox VE: a PowerShell module that talks to the management API, with objects in the pipeline. This page maps the PowerCLI cmdlets you use most to their equivalent here, and lists the differences that trip people up in the first scripts.

The PowerCLI cmdlet names come from the official PowerCLI reference (modules VMware.VimAutomation.Core and VMware.VimAutomation.Common).

vSphere Proxmox VE In the module
vCenter Server No separate management server: every node serves the API for the whole cluster Connect to any node; list several and the first that answers is used: see Connection
ESXi host Node Get-PveNode
Virtual machine VM (QEMU/KVM) or LXC container, with different endpoints Get-PveGuest returns both, with type qemu or lxc
VMware Tools QEMU guest agent (VMs only) …QemuAgent… cmdlets: see Guest agent
Datastore Storage, defined for the whole cluster, shared or local to a node Get-PveClusterResources -Type storage
Resource pool Pool: a group of guests and storages used for permissions, without CPU or memory limits Get-PvePools
Tags Tags on the guest, separated by ; the tags property of Get-PveGuest
$global:DefaultVIServer The last connection $PveTicketLast: see Connection
PowerCLI cv4pve-api-powershell
Connect-VIServer Connect-PveCluster
Get-VM Get-PveGuest: by id, name, range, node, pool or tag, with exclusions, see Finding VMs
Get-VMHost Get-PveNode
Get-Datastore Get-PveClusterResources -Type storage
Get-ResourcePool Get-PvePools
Get-TagAssignment Get-PveGuest -VmIdOrName '@tag-web', or the tags property
Get-VMGuest Get-PveNodesQemuAgentGetOsinfo, Get-PveNodesQemuAgentNetworkGetInterfaces
PowerCLI cv4pve-api-powershell
Start-VM Start-PveGuest
Stop-VM Stop-PveGuest: immediate stop, as Stop-VM
Stop-VMGuest Stop-PveGuest -Shutdown: clean shutdown through the guest
Restart-VM Reset-PveGuest: reset of the VM
Restart-VMGuest Restart-PveGuest: reboot through the guest
Suspend-VM Suspend-PveGuest; Resume-PveGuest to resume

See Power and lock.

PowerCLI cv4pve-api-powershell
Get-Snapshot Get-PveGuestSnapshot
New-Snapshot -Memory New-PveGuestSnapshot -Vmstate
Set-VM -Snapshot Undo-PveGuestSnapshot
Remove-Snapshot Remove-PveGuestSnapshot

See Snapshots.

PowerCLI cv4pve-api-powershell
Move-VM to another host (vMotion) New-PveNodesQemuMigrate -Target pve02 -Online $true; containers New-PveNodesLxcMigrate -Target pve02 -Restart $true
Move-VM to another datastore (Storage vMotion) New-PveNodesQemuMoveDisk -Disk scsi0 -Storage <storage>; containers New-PveNodesLxcMoveVolume
Move-HardDisk New-PveNodesQemuMoveDisk
Move-VM with host and datastore New-PveNodesQemuMigrate -Target pve02 -WithLocalDisks $true -Targetstorage <storage>
New-VM New-PveNodesQemu, New-PveNodesLxc: see Create a VM
New-VM -Template New-PveNodesQemuClone
Invoke-VMScript New-PveNodesQemuAgentExec: see Guest agent
Get-Task, Wait-Task Get-PveNodesTasks, Wait-PveTaskIsFinish: see Tasks
Get-Stat Get-PveNodesQemuRrddata -Timeframe hour (alias Get-PveQemuMonitoring), Get-PveNodesLxcRrddata
Get-View Invoke-PveRestApi: any path of the API, see Raw API

New-PveNodesQemuMoveDisk without -Delete $true keeps the original disk on the VM as an unused disk.

Every other endpoint of the API has its cmdlet: search it in the cmdlet reference, grouped like the API.

PowerCLI returns the objects. Here the functions written for convenience (Get-PveGuest, Get-PveNode) do too, but the generated cmdlets return a PveResponse, with the data in .Response.data:

$vm = Get-PveGuest -VmIdOrName web01 # the guest itself
(Get-PveNodesQemuConfig -Node $vm.node -Vmid $vm.vmid).Response.data.memory # memory in MiB

See Results.

A PowerCLI cmdlet that fails writes an error that -ErrorAction Stop turns into an exception. A generated cmdlet here returns a PveResponse with IsSuccessStatusCode $false and the reason in ReasonPhrase: check it, or wrap the calls. See Errors.

PowerCLI finds a VM by name anywhere in vCenter. The generated cmdlets follow the API paths, which include the node: -Node pve01 -Vmid 100. Pipe Get-PveGuest into them, and it fills -Node and -Vmid for you:

Get-PveGuest -VmIdOrName web01 | Get-PveNodesQemuConfig

Where PowerCLI has switches, the generated cmdlets have [bool] parameters, because the API can set them to false: -Online $true, -Onboot $false. See Parameters.

The cmdlets that change something take the standard PowerShell parameters -WhatIf and -Confirm: Remove-PveNodesQemu … -WhatIf, Stop-PveGuest -VmIdOrName '@tag-lab' -WhatIf. They never ask by themselves: see -WhatIf and -Confirm.

vSphere has one kind of guest. Proxmox VE has VMs (qemu) and containers (lxc), each with its own endpoints: Get-PveNodesQemuConfig or Get-PveNodesLxcConfig. The functions written for convenience (Start-PveGuest, the snapshot functions) choose for you; with the generated cmdlets, filter on type first.