How to export VMware virtual machine from ESXi or VCSA using PowerCLI

To export a virtual machine from the VCSA you can use either VCSA client (HTML5 or Flex). Since neither of these methods is reliable enough, you can export it using PowerCLI and PowerShell interface on your PC or MAC. In this example I will use a virtual machine named v-srv01. Please note that export VM function is available only in commercial versions of ESXi server and any version of VCSA.

Values written in red are to reflect your own environment and needs.

To export a VM, first, we need to connect to the VCSA:

# Connect-VIServer v-vcsa01.sefnet.tech

The next step is to check if the VM has any snapshots. If they exist, you need to remove all the snapshots before exporting the VM:

# Get-Snapshot -Name v-srv01 | Remote-Snapshot -confirm:$false

Make sure that the VM is in Powered Off state:

# Get-VM -Name v-srv01 | Shutdown-VMGuest -confirm:$false

Make sure no ISO image is connected to the VM. If any connected, disconnect is using the following command:

# Get-VM -Name v-srv01 | Get-CDDrive | Set-CDDrive -NoMedia -confirm:$false

Now we export our VM. Use either OVA (single file) or OVF (Folder of files) format:

# Get-VM -Name v-srv01 | Export-VApp -Destination '/Volume/X7/VM/Export/v-srv01' -Format OVA

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.