In this blog post, it’s my aim to show you the most popular commands for Citrix XenServer in PowerShell and Command line, so you can use them in your automation workflow.
Because, as always, AUTOMATE EVERYTHING! Citrix XenServer is Linux-based, so in the command line, you can use Linux commands like ls-l or mount. But it also has its own command lines starting with XE in the linux shell and is also available on Windows and installed together with XenCenter: “C:\Program Files (x86)\Citrix\XenCenter\xe.exe” . This post will include those command lines and the PowerShell commands. To get PowerShell working with Citrix XenServer, you need to download and install the XenServer SDK from here, under the Development Components section.
To install the PowerShell SDK, you need to copy the PowerShell Module folder from the zip to $env:windir\system32\WindowsPowerShell\v1.0\Modules. To enable the module, use the following command: Import-Module XenServerPSModule.
Command list:
- Connect to XenServer
- New VM
- Delete VM
- Change VM Specs
- Add Disk to VM
- Change VM Description
- Export VM
- Create Snapshot
- Delete Snapshot
- Start VM
- Stop VM
- Reboot VM
- Get VM List
- Get Template List
- Get Snapshot List
Connect to XenServer
PowerShell:
Command line
Open a SSH connection with a SSH tool like PuTTY or use the console tab in XenCenter when you select your XenServer host.
New VM
PowerShell:
From Template (Example uses Windows Server 2016 Template)
PowerShell:
Command Line:
Delete VM
Power Shell:
Command Line:
Change VM Specs
PowerShell:
Increase RAM and vCPU
Decrease vCPU and RAM
Command Line
Change RAM
Add more vCPUs
Remove vCPUs
Add Disk to VM
PowerShell:
Command Line:
Change VM Description
PowerShell:
Command Line:
Export VM
PowerShell:
Create Snapshot
PowerShell:
Command Line:
Delete Snapshot
Power Shell:
Command Line:
Start VM
PowerShell:
Command Line:
Stop VM
Power Shell:
Reboot VM
PowerShell:
Command Line:
Get VM List
PowerShell:
Command Line:
Get Template List
PowerShell:
Command Line:
Get Snapshot List
PowerShell:
Command Line:
Now, with these commands in hand, you can do a lot of things, such as creating your own XenServer backup script, deploying VMs automatically, automatically shutting down VMs at night to save power, automatically creating an isolated test environment, and so on. With PowerShell and XenServer, the possibilities are endless!
Are you missing some PowerShell or command line commands in this list? Please leave a comment or visit the Citrix Discussion Forums.
If you want to read more about scripting and automating, take a look at my own blog site https://workspace-guru.com
Chris Twiest is Senior Workspace IT consultant at Detron in the Netherlands. With more than 10 years of experience in managing and creating workspace environments, Chris is a Citrix Certified Professional, is an active member of CUGC — the Citrix User Group Community — and has a strong focus on PowerShell and Citrix products.
Citrix TechBytes – Created by Citrix Experts, made for Citrix Technologists! Learn from passionate Citrix Experts and gain technical insights into the latest Citrix Technologies.
Click here for more TechBytes and subscribe.
Want specific TechBytes? Let us know! tech-content-feedback@citrix.com