Get-XenVM

Last published : Nov 12, 2026
Gets the VM objects in the pool.

Syntax

Get-XenVM [[-Ref] <XenRef[VM]>] [-BestEffort] [-SessionOpaqueRef <string>]
    [<CommonParameters>]
Get-XenVM [-Uuid] <guid> [-BestEffort] [-SessionOpaqueRef <string>] [<CommonParameters>]
Get-XenVM [-Name] <string> [-BestEffort] [-SessionOpaqueRef <string>] [<CommonParameters>]

Description

Retrieves the VM objects in the pool. With no parameters the cmdlet returns the whole collection; use -Name, -Uuid or -Ref to select one.
VM: A virtual machine (or 'guest').

Parameters

-BestEffort

If set, the cmdlet continues processing further objects instead of throwing a terminating error when an operation fails for one object.
Attribute Value
Type SwitchParameter
Required False
Position Named
Accepts pipeline input False

-Name

The name of the VM to operate on.
Attribute Value
Type string
Required True
Position 0
Accepts pipeline input True (ByPropertyName)
Aliases name_label

-Ref

The VM object to operate on, specified by its opaque reference.
Attribute Value
Type XenRef[VM]
Required False
Position 0
Accepts pipeline input True (ByPropertyName)
Aliases opaque_ref

-SessionOpaqueRef

The session object on which to run the cmdlet. This overrides the default session and lets you target a specific open XenServer connection.
Attribute Value
Type string
Required False
Position Named
Accepts pipeline input False

-Uuid

The UUID of the VM to operate on.
Attribute Value
Type guid
Required True
Position 0
Accepts pipeline input True (ByPropertyName)

Inputs

  • XenRef[VM]
  • guid
  • string

Outputs

  • VM[]

Examples

Example 1: List every VM

PS> Get-XenVM
Retrieves every VM object in the pool. With no parameters the cmdlet fetches the whole collection.

Example 2: List the running VMs

PS> Get-XenVM | Where-Object { $_.power_state -eq "Running" }
Every field of the XenAPI record is a property of the returned object, so the objects are filtered with Where-Object rather than by a cmdlet parameter. The property names are the API's, in their original spelling.

Example 3: Find the templates

PS> Get-XenVM | Where-Object { $_.is_a_template }
Templates are VM objects with is\_a\_template set, not a separate class, so there is no Get-XenTemplate; this is how you list the templates a new VM can be cloned from.

Example 4: Retrieve one VM and read a field

PS> $vm = Get-XenVM -Name "web-01"
PS> $vm.memory_static_max
-Name matches on name\_label, which is not unique: the cmdlet returns every match. Use -Uuid where you need exactly one object.
  • Class: VM
  • Using the XenServer PowerShell module