OVA KB ID 0001507
Problem : Creating OVA files
It’s pretty easy to create an OVA/OVF from the vCenter Web console, but what about from Powershell / PowerCLI? Below I run though converting a Windows server to OVA.
Note: Update 25/03/25 – Had a friend try and do this today, the VM was very large (over 12Tb) it proceeded to create the conversion in the servers c:\windows\temp directory. Obviously, this is not good! If you encounter this, then change the system variables for %TEMP% and %TMP% to the drive/partition you watn to send the OVA to (Warning: this required a reboot to take effect).
Solution: Powershell > OVA
I’ll leave the web console in the background so you can see what’s happening. From PowerCLI the first task is to connect to the vCenter.
Supply a username and password.
Now remove any snapshots from the VM;
The VM needs to be off before we can export it, the following command will shut it down gracefully;
If your VM has an ISO connected to it, it can have an annoying habit of adding that to the OVA file! So remove any presented .iso files with the following command.
Finally we export our VM.
Related Articles, References, Credits, or External Links
VMware vSphere – How to Import and Export OVF and OVA Files
VMware: ISO Upload or Deploy OVA Fails ‘Undetermined Reason’
13/05/2020
Hi Pete,
Thanks for the instruction for exporting to OVA with PowerCLI. I am reasonably new to PowerCLI and can see the benefits. Just some reason, the syntax “Export-VApp” will error:
Export-VApp : 13/05/2020 9:15:01 AM Export-VApp Current license or ESXi version prohibits execution of the requested operation.
At line:1 char:51
+ … iance_v1200_dhcp_1″ | Export-VApp -Destination “C:\Utils” -Format OVA
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Export-VApp], RestrictedVersion
+ FullyQualifiedErrorId : Client20_VappServiceImpl_ExportVApp_Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.ExportVApp
I am running ESXi 607; do you have any idea what the issue is?, thank you.
15/05/2020
Yes, you are using FREE ESX that does not support all the storage APIs sorry.
01/01/2021
Thank you for this article, In it the vm’s get powered off to do the conversion but is there a way to have them power back on once the vmware is completed doing the ova? I know it is easy to power the vm’s on with cli but how do you check if ova completed before powering on?
18/01/2021
Capture the output of the Export-VApp, like this:
$ovfExport = Export-VApp
Then you can access the State property to see if it is running like so…
if ($ovfExport.State -ne “Running”) {
Start-VM -vm
}
The if will only trigger when the Export-VApp is Done or the State is Error. How you check errors is a different conversation though.
15/11/2021
Thank you !!!!
08/07/2022
Thank you! Very clear and working case.