KB ID 0001507
Problem
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 2008 x32 Windows server to OVA.
Solution
I’ll leave the web console in the background so you can see whats happening. From PowerCLI the first task is to connect to the vCenter.
[box]Connect-VIServer {vCenter-FQDN}[/box]
Supply a username and password.
Now remove any snapshots from the VM;
[box]Get-Snapshot Test-VM | Remove-Snapshot -confirm:$false[/box]
The VM needs to be off before we can export it, the following command will shut it down gracefully;
[box]Get-VM -Name Test-VM | Shutdown-VMGuest -confirm:$false[/box]
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;
[box]Get-VM -Name Test-VM | Get-CDDrive | Set-CDDrive -NoMedia -confirm:$false[/box]
Finally we export our VM;
[box]Get-VM -Name Test-VM | Export-VApp -Destination ‘E:\Exported‘ -Format OVA[/box]
Related Articles, References, Credits, or External Links
NA