Automation

 View Only
Expand all | Collapse all

Export VM as an OVA file using powercli - unexpected error

LucD

LucDMay 05, 2015 07:41 PM

  • 1.  Export VM as an OVA file using powercli - unexpected error

    Posted May 05, 2015 03:45 PM

    I am trying to export an ova-file using powercli but with no success. It do work when I login with the same user in the vSphere client but not with powercli.

    Get-VM -Name "my test VM 150505 12345" | Export-VApp -Destination "L:\Backup 150505\" -Format Ova

    Export-VApp : 2015-05-05 17:22:46    Export-VApp        Object reference not set to an instance of an object.

    At line:1 char:42

    + Get-VM -Name "my test VM 150505 12345" | Export-VApp -Destination "L:\Backup 150 ...

    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

        + CategoryInfo          : NotSpecified: (:) [Export-VApp], ViError

        + FullyQualifiedErrorId : Client20_NfcLease_RunNfcTask_Error,VMware.VimAutomation.ViCore.Cmdlets.Commands.ExportVApp

    I have also tried to use the -VM parameter insted of pipelining with the same result.

    * I have verified that the VM does exist - $vm = Get-VM -name "my test VM 150505 12345" does work.

    * When I run the command above, I can see that the ...ova.tmp file is created in the directory and then deleted prior to the error.

    * In the vSphere client, the "Recent Tasks" says "Export OVF template ...... The task was canceled by a user."

    Thank you for any suggestions/hints.

    /Mats



  • 2.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted May 05, 2015 07:41 PM

    Is the VM powered on ?



  • 3.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted May 06, 2015 08:21 AM

    No it is powered off but a good idea (I had to check).



  • 4.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted May 06, 2015 08:44 AM

    This error message is a bit of a catch all I'm afraid.

    Is there anything in the vpxd log that could be used to determine the actual issue ?

    Perhaps you could also check the vmware.log of the VM ?



  • 5.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted May 06, 2015 09:46 AM

    Thank you!

    In the vpxa.log on the host, in says among others "[HTTP-NFC-TICKET 525b...f36] Revoked"

    So I tried to export a VM from another host and that did work perfectly, so it's a problem with the host.

    Thank you for your help!

    /Mats



  • 6.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Mar 24, 2016 08:48 PM

    I am receiving the same error and I don't believe the host is the issue.  It is happening for me on at least 3 different 4.1 hosts.  As a test I created a new blank VM, placed it on that host, and the powercli export is successful.  So far my script is only successful if I export as an OVF as opposed to OVA.  Any other suggestions?



  • 7.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Mar 25, 2016 06:47 AM

    I have seen mentions where the VM you are trying to export was configured with a static IP.

    Once the VM was reconfigured to use DHCP, the export worked.

    A wild guess, but perhaps worth a try.

    Also check the vpxd log.

    Or did you already do that, and saw the same message that was mentioned ?



  • 8.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Mar 25, 2016 01:33 PM

    Thanks for replying LucD.  Hmm that is going to be a problem if it has to do with static IPs, as these are retired servers we are archiving.  The servers are all off, so I wouldn't think the static IP would interfere.  If it is, do you think removing the NIC altogether would help?

    Yes I have verified in the vpxa.log on the host that I also have the same error.  Here is what I have:

    [2016-03-25 13:20:31.002 info 'App' opID=59332ed5-8f-9b] [VpxLRO] -- BEGIN task-internal-1344488 --  -- vpxapi.VpxaService.addHttpNfcTicket -- 52d52b3d-0efa-32d1-2560-57c50757fb83

    [2016-03-25 13:20:31.002 info 'App' opID=59332ed5-8f-9b] [HTTP-NFC-TICKET af91e5cf-0bd1-44ee-94fc-dcc2d385f51a] Renewed

    [2016-03-25 13:20:31.002 info 'App' opID=59332ed5-8f-9b] [HTTP-NFC-TICKET] Created ticket af91e5cf-0bd1-44ee-94fc-dcc2d385f51a

    [2016-03-25 13:20:31.002 verbose 'App' opID=59332ed5-8f-9b] [VpxURL] Resolved URL netfs://128.231.95.223//RetiredDatastore/_Retired_server1/_Retired_server1.vmdk to localPath /vmfs/volumes/fbf6b546-c19a90

    [2016-03-25 13:20:31.003 info 'App' opID=59332ed5-8f-9b] [HTTP-NFC-TICKET af91e5cf-0bd1-44ee-94fc-dcc2d385f51a] Adding file </vmfs/volumes/fbf6b546-c19a90e7/_Retired_server1/_Retired_server1.vmdk>

    [2016-03-25 13:20:31.003 info 'App' opID=59332ed5-8f-9b] [HTTP-NFC-TICKET] URL /vm-589/VirtualLsiLogicController0:0 -> disk-0.vmdk

    [2016-03-25 13:20:31.003 verbose 'App' opID=59332ed5-8f-9b] [VpxURL] Resolved URL netfs://128.231.95.223//RetiredDatastore/_Retired_server1/_Retired_server1_1.vmdk to localPath /vmfs/volumes/fbf6b546-c19a

    [2016-03-25 13:20:31.004 info 'App' opID=59332ed5-8f-9b] [HTTP-NFC-TICKET af91e5cf-0bd1-44ee-94fc-dcc2d385f51a] Adding file </vmfs/volumes/fbf6b546-c19a90e7/_Retired_server1/_Retired_server1_1.vmdk>

    [2016-03-25 13:20:31.004 info 'App' opID=59332ed5-8f-9b] [HTTP-NFC-TICKET] URL /vm-589/VirtualLsiLogicController0:1 -> disk-1.vmdk

    [2016-03-25 13:20:31.004 verbose 'SoapAdapter.HTTPService' opID=59332ed5-8f-9b] HTTP Response: Complete (processed 760 bytes)

    [2016-03-25 13:20:31.004 info 'App' opID=59332ed5-8f-9b] [VpxLRO] -- FINISH task-internal-1344488 --  -- vpxapi.VpxaService.addHttpNfcTicket -- 52d52b3d-0efa-32d1-2560-57c50757fb83

    [2016-03-25 13:20:31.057 verbose 'SoapAdapter.HTTPService'] User agent is 'VMware-client/4.1.0'

    [2016-03-25 13:20:31.057 verbose 'SoapAdapter.HTTPService'] User agent is 'VMware-client/4.1.0'

    [2016-03-25 13:20:31.057 verbose 'SoapAdapter.HTTPService'] HTTP Response: Client: NeedsContentLength: false UnderstandsChunking: true CanKeepAlive: true (PresetContentLength 129)

    [2016-03-25 13:20:31.057 verbose 'SoapAdapter.HTTPService'] HTTP Response: Client: NeedsContentLength: false UnderstandsChunking: true CanKeepAlive: true (PresetContentLength -1)

    [2016-03-25 13:20:31.058 verbose 'SoapAdapter.HTTPService'] HTTP Response: Auto-completing at 129/129 bytes

    [2016-03-25 13:20:31.058 info 'App' opID=c6f2a54-f1] [VpxLRO] -- BEGIN task-internal-1344489 --  -- vpxapi.VpxaService.destroyHttpTicket -- 52d52b3d-0efa-32d1-2560-57c50757fb83

    [2016-03-25 13:20:31.059 info 'App' opID=c6f2a54-f1] [HTTP-NFC-TICKET af91e5cf-0bd1-44ee-94fc-dcc2d385f51a] Revoked

    [2016-03-25 13:20:31.059 verbose 'SoapAdapter.HTTPService' opID=c6f2a54-f1] HTTP Response: Complete (processed 400 bytes)

    [2016-03-25 13:20:31.059 info 'App' opID=c6f2a54-f1] [VpxLRO] -- FINISH task-internal-1344489 --  -- vpxapi.VpxaService.destroyHttpTicket -- 52d52b3d-0efa-32d1-2560-57c50757fb83

    [2016-03-25 13:20:32.148 verbose 'VpxaHalCnxHostagent'] Received callback in WaitForUpdatesDone

    [2016-03-25 13:20:32.148 verbose 'VpxaHalCnxHostagent'] [VpxaHalCnxHostagent::ProcessUpdate] Applying updates from 3719558 to 3719559 (at 3719558)

    [2016-03-25 13:20:32.149 verbose 'App'] [VpxaHalVmHostagent] 2944: GuestInfo changed 'guest.disk'

    [2016-03-25 13:20:32.149 verbose 'App'] [VpxaHalServices] VmGuestDiskChange Event for vm(67) 2944

    [2016-03-25 13:20:32.149 verbose 'App'] [VpxaInvtVmChangeListener] Guest DiskInfo Changed



  • 9.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Mar 25, 2016 02:42 PM

    As I said that is a wild guess, it seems to have helped in some cases.

    Yes, perhaps removing the NIC is a valid alternative, but make sure you can revert (backup/snapshot)



  • 10.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Apr 05, 2016 12:08 PM

    Hello,

    I experienced exactly the same issue (export OK without "-Format Ova" option, systematic error message as you described with this OVA option).

    Cannot exactly find out why, but I just noticed it seemed to be linked with space character (" ") included in the VM name.

    Obviously the same conditions were met in the original post from Mats O, I don't know if you meet them too (I didn't see reference of your VM name).

    If it is the case, could you try to clone+rename your VM (with no space in it) and try again apply the OVA export on the clone ?



  • 11.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Apr 05, 2016 03:36 PM

    Thanks for the reply.  There are no spaces in the name but I think you were on the right track.  I actually just tried again and it looks like parentheses are illegal characters for the Export-Vapp function to OVA format.  It's pretty odd because if you manually create an OVA of the same name with parentheses it succeeds.  For now I have renamed the VMs without spaces and parentheses and this seems to have resolved the issue.  FYI, dashes and underscores are allowed.  Thanks all for the help!



  • 12.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Apr 06, 2016 08:36 PM

    I may not actually be out of the woods yet.  After the OVA files completed, we decided to try to deploy an OVF template from one of these files to test restoring a VM.  The process got to 100% and then complained of a bad checksum.  I read in another post that converting the OVA to an OVF can solve the issue.  This process also failed stating "-- Wrong file size specified in OVF Descriptor".

    Are there any other arguments in Export-Vapp to make this work correctly?



  • 13.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Apr 27, 2016 04:24 PM

    Hello,

    Guess what ?

    I issued the same test and got a similar result : VM restoration from .OVA fails, due to .vmdk file integrity pb (suspected to be corrupted during transfer),

    Then I tried the backup / restore process using VCenter graphical environment (VM being unchanged / stopped in-between), which succeeded.

    Moving further I just learnt OVA files use a standard compressed archive format, so I try to compare the OVA I got from PowerCLI export with the one I obtained through VCenter GUI, outside of the VMWare environnement.

    Decompressing those archives (simply using 7Zip) I got for each :

    - 1 "<vm_name>.mf" file containing SHA1 signature of 2 following files

    - 1 "<vm_name>.ovf"

    - 1 "<vm_name>_diskN.vmdk"

    N.B. Note that vmdk filenames differ : "blabla_disk0.vmdk" / "blabla_disk1.vmdk" (is this normal ?)

    I ran a checksum utility which confirmed SHA1 computation gives a coherent result for the "VCenter GUI OVA" .vmdk extracted file (same as the one stated in the mf file)

    whereas the result is different for the "PowerCLI OVA", so I guess either the SHA1 mentioned on the mf file is false, or this file is actually corrupted which is more likely...

    (Of course I repeated the operation several times, all resulting with the same file integrity error)

    Same as you, I can't understand this Export-VApp issue...

    Any suggestion for a possible workaround... ?



  • 14.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Apr 27, 2016 07:44 PM

    What version of VMWare are you running?  I experienced the issue in 4.1 but on my 5.5 instance, I am able to successfully restore OVA files without a bad checksum error.



  • 15.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Apr 28, 2016 05:26 PM

    Actually I face the problem using VCenter 5.5 / Vsphere 5.5.

    I issued another test removing -format OVA option in the export-VApp command

    in this case the backup / restore operation seems to be correct using OVF format instead of OVA...



  • 16.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Aug 17, 2016 07:18 AM

    Same issue here

    However, I have managed to get Export-Vapp command (to an OVA) to work by using two methods, either:

    1) Use a static string as the Name parameter, and not a variable (not very efficient when scripting a group of VM exports)

    Example:

    export-vapp -destination $dest -VM $vm -Format OVA -Name MyVMName

    2) Set a $Name variable, ensuring no spaces in the resulting string....

    Example:

    $Name = ($vm.name).replace(" ","_")

    export-vapp -destination $dest -VM $vm -Format OVA -Name $Name

    I have tried using foreach loops in conjunction with example 2 but canot get this to work, so have resorted to a foreach loop with example 1

    $dest = "C:\OVFS\"

    $vms = get-folder Test* | get-vm

    foreach ($vm in $vms)

    {

        if ($vm.Name -like "PRODSQL01*")    { Export-VApp -Destination $dest -VM $vm -Format OVA -Name ProdSQL01 -RunAsync | out-null}

        if ($vm.Name -like "PRODEXCH01*") { Export-VApp -Destination $dest -VM $vm -Format OVA -Name ProdExch01 -RunAsync | out-null }

        write-host "Exporting -->" $vm.Name -ForegroundColor Yellow

    }

    Enjoy



  • 17.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Jan 13, 2018 04:23 PM

    @VM_Darren:

    Thank you for the hint with the replacement of " ".

    I have renamed all my VMs containing blanks or special characters and now it is working fine!



  • 18.  RE: Export VM as an OVA file using powercli - unexpected error

    Posted Feb 19, 2020 06:08 PM

    Thanks, your approach of setting the name to something without a space worked for me as well.

    I'm surprised this is necessary, VMware should definitely fix this bug on their end.