A PowerShell module to interact with Xen Orchestra's REST API, allowing you to manage your XenServer/XCP-ng virtualization environment directly from PowerShell.
- PowerShell 7.0 or later
- Access to a Xen Orchestra instance
- A valid API token
You can install from sources or from the PowerShell Gallery (easier).
Install-Module -Name xo-powershell -AllowPrerelease- Clone this repository or download the module files
- Place them in a directory of your choice
- Import the module:
Import-Module ./xo-powershell.psd1You need to authenticate with your Xen Orchestra instance before running commands:
Connect-XoSession -HostName "https://your-xo-server" -Token "your-api-token"Test-XoSession- Test connection to Xen OrchestraConnect-XoSession- Connect to Xen Orchestra (Connect-XenOrchestrais an alias)Disconnect-XoSession- Disconnect from Xen Orchestra (Disconnect-XenOrchestrais an alias)
Get-XoVm- Get list of VMs or a specific VMStart-XoVm- Start one or more VMsStop-XoVm- Stop one or more VMs (use -Force for hard shutdown)Restart-XoVm- Restart one or more VMs (use -Force for hard reboot)New-XoVmSnapshot- Create VM snapshotGet-XoVmSnapshot- Get VM snapshotsSuspend-XoVm- Suspend one or more VMs
Get-XoSr- Get storage repositoriesGet-XoVdi- Get virtual disk imagesGet-XoVmVdi- Get disks attached to a VMExport-XoVdi- Export a VDI to a file in VHD or RAW format
Get-XoVdiSnapshot- Get VDI snapshotsExport-XoVdiSnapshot- Export a VDI snapshot to a file in VHD or RAW format
Get-XoServer- Get server information
Get-XoHost- Get host information
Get-XoTask- Get task information (Get-XoTaskDetailsis an alias)Wait-XoTask- Wait for task completion
List all running VMs:
Get-XoVm -PowerState RunningGet a specific VM:
Get-XoVm -VmUuid "12345678-abcd-1234-abcd-1234567890ab"Start multiple VMs:
Get-XoVm -PowerState Halted | Start-XoVmCreate a snapshot of a VM:
New-XoVmSnapshot -VmUuid "12345678-abcd-1234-abcd-1234567890ab" -SnapshotName "Before Update"Get all disks for a VM:
Get-XoVmVdi -VmUuid "12345678-abcd-1234-abcd-1234567890ab"Export a VDI to a file:
Export-XoVdi -VdiId "a1b2c3d4" -Format vhd -OutFile "C:\exports\disk_backup.vhd"List all servers:
Get-XoServerList all hosts:
Get-XoHostMost commands support pipeline input, allowing for operations like:
Get-XoVm | Where-Object { $_.Name -like "*Test*" } | Stop-XoVmGet-XoVm -PowerState Running | Where-Object { $_.Memory -gt 4GB } | Suspend-XoVmContributions are welcome! Please feel free to submit a Pull Request.