SHamel5575
Enthusiast
Enthusiast

Unable to Export-vm on newest version of Powercli

Jump to solution

Im trying to export some powered off VM's to move between environments, and when i run the export-vm command i get an error.    When i run the same command on a machine with the older version of powercli (5.5 release 2)  it exports fine.   Im running the commands against a vcenter 6.5 environment.   I have tried the new powercli from several machines with the same results.  I dont know if theres a bug in the export command, or if something has changed in the syntax.  Any help would be appreciated.

PS C:\Windows\system32> get-vm VM_Name|export-vm -destination d:\

export-vm : 5/29/2019 3:50:12 PM        Export-VApp             An error occurred while sending the request.

At line:1 char:24

+ get-vm VM_Name|export-vm -destination d:\

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

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

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

   pp

Heres what i have installed

PS C:\Windows\system32> Get-Module -Name VMware* -ListAvailable

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    Name                                ExportedCommands

---------- -------    ----                                ----------------

Script     6.7.0.1... VMware.DeployAutomation             {Add-DeployRule, Add-ProxyServer, Add-ScriptBundle, Copy-D...

Script     6.7.0.1... VMware.ImageBuilder                 {Add-EsxSoftwareDepot, Add-EsxSoftwarePackage, Compare-Esx...

Manifest   11.2.0.... VMware.PowerCLI

Script     6.7.0.1... VMware.Vim

Script     11.2.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, Disconnect-CisServer, Get-CisService}

Script     11.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, Connect-CIServer, Disconnect-CIServer, G...

Script     11.2.0.... VMware.VimAutomation.Common

Script     11.2.0.... VMware.VimAutomation.Core           {Add-PassthroughDevice, Add-VirtualSwitchPhysicalNetworkAd...

Script     11.2.0.... VMware.VimAutomation.Hcx            {Connect-HCXServer, Disconnect-HCXServer, Get-HCXAppliance...

Script     7.6.0.1... VMware.VimAutomation.HorizonView    {Connect-HVServer, Disconnect-HVServer}

Script     10.0.0.... VMware.VimAutomation.License        Get-LicenseDataManager

Script     11.2.0.... VMware.VimAutomation.Nsxt           {Connect-NsxtServer, Disconnect-NsxtServer, Get-NsxtPolicy...

Script     11.2.0.... VMware.VimAutomation.Sdk            {Get-ErrorReport, Get-InstallPath, Get-PSVersion}

Script     11.0.0.... VMware.VimAutomation.Security       {Get-SecurityInfo, Get-VTpm, Get-VTpmCertificate, Get-VTpm...

Script     11.2.0.... VMware.VimAutomation.Srm            {Connect-SrmServer, Disconnect-SrmServer}

Script     11.2.0.... VMware.VimAutomation.Storage        {Add-KeyManagementServer, Copy-VDisk, Export-SpbmStoragePo...

Script     1.3.0.0    VMware.VimAutomation.StorageUtility Update-VmfsDatastore

Script     11.2.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysicalNetworkAdapter, Add-VDSwitchVMHost, E...

Script     11.2.0.... VMware.VimAutomation.Vmc            {Connect-Vmc, Disconnect-Vmc, Get-VmcSddcNetworkService, G...

Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer, Disconnect-OMServer, Get-OMAlert, Get-O...

Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaseline, Copy-Patch, Get-Baseline, Get-Complia...

PS C:\Windows\system32>

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
SHamel5575
Enthusiast
Enthusiast

I figured it out.

I had to install the vCenter trusted root CA certificates on the machine i was running the export from.  They must be installed on the machine with the older powercli.

Thanks for your help.

View solution in original post

0 Kudos
23 Replies
LucD
Leadership
Leadership

No, nothing has changed on the Export-VM cmdlet.
In fact, I just tried your line with PowerCLI 11.2.0, and the export is working without an issue.


The error message seems to indicate something goes wrong with the NFS lease.
Can you check the vpxd log to see if there are any clues on what goes wrong?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

Where would i find the vpxd log i should be looking at?

0 Kudos
LucD
Leadership
Leadership

It's on the vCenter.
If you use the Web Client, select the vCenter, then Monitor - System Logs


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

2019-05-30T15:32:38.279Z info vpxd[7F05BA2A0700] [Originator@6876 sub=vpxLro opID=2669013f-01] [VpxLRO] -- BEGIN task-731693 -- VM_Name -- VirtualMachine.ExportVmLRO --

2019-05-30T15:32:38.284Z info vpxd[7F05BA2A0700] [Originator@6876 sub=MoHttpNfcLease opID=2669013f-01] [HttpNfcLease] Host URL: https://ESXIHost/nfc/52333b1b-03d0-3bf1-e06b-6f2826fc8d4a/, target ID: disk-0.vmdk

2019-05-30T15:32:38.297Z info vpxd[7F04BB3E7700] [Originator@6876 sub=vpxLro opID=2953962e] [VpxLRO] -- BEGIN lro-8853832 -- session[52094fe6-49e4-91de-25a9-4dc8cf216c6e]52991591-3d7a-ba7d-e17f-ad91dbb0c4ff -- vim.HttpNfcLease.progress -- 52094fe6-49e4-91de-25a9-4dc8cf216c6e(5285ed6c-cd00-3187-6bef-0434712fa0e6)

2019-05-30T15:32:38.297Z info vpxd[7F05BA2A0700] [Originator@6876 sub=VAppExport opID=2669013f-01] [ExportTaskMo] Progress: 0

2019-05-30T15:32:38.297Z info vpxd[7F04BB3E7700] [Originator@6876 sub=vpxLro opID=2953962e] [VpxLRO] -- FINISH lro-8853832

2019-05-30T15:32:38.303Z info vpxd[7F04BA850700] [Originator@6876 sub=vpxLro opID=2ea8bb34] [VpxLRO] -- BEGIN lro-8853833 -- OvfManager -- vim.OvfManager.createDescriptor -- 52094fe6-49e4-91de-25a9-4dc8cf216c6e(5285ed6c-cd00-3187-6bef-0434712fa0e6)

2019-05-30T15:32:38.304Z info vpxd[7F04BA850700] [Originator@6876 sub=vpxLro opID=2ea8bb34] [VpxLRO] -- FINISH lro-8853833

2019-05-30T15:32:38.323Z info vpxd[7F04BBAF5700] [Originator@6876 sub=vpxLro opID=479a6ada] [VpxLRO] -- BEGIN lro-8853834 -- session[52094fe6-49e4-91de-25a9-4dc8cf216c6e]52991591-3d7a-ba7d-e17f-ad91dbb0c4ff -- vim.HttpNfcLease.abort -- 52094fe6-49e4-91de-25a9-4dc8cf216c6e(5285ed6c-cd00-3187-6bef-0434712fa0e6)

2019-05-30T15:32:38.323Z info vpxd[7F04BBAF5700] [Originator@6876 sub=MoHttpNfcLease opID=479a6ada] [HttpNfcLeaseMo] Releasing HTTP-NFC ticket

2019-05-30T15:32:38.323Z info vpxd[7F05BA2A0700] [Originator@6876 sub=vpxLro opID=2669013f-01] [VpxLRO] -- FINISH task-731693

2019-05-30T15:32:38.323Z info vpxd[7F05BA2A0700] [Originator@6876 sub=Default opID=2669013f-01] [VpxLRO] -- ERROR task-731693 -- VM_Name -- VirtualMachine.ExportVmLRO: vmodl.fault.RequestCanceled:

--> Result:

--> (vmodl.fault.RequestCanceled) {

-->    faultCause = (vmodl.MethodFault) null,

-->    faultMessage = <unset>

-->    msg = ""

--> }

--> Args:

-->

2019-05-30T15:32:38.325Z info vpxd[7F04BBAF5700] [Originator@6876 sub=MoHttpNfcLease opID=479a6ada] Task aborted, scheduling lease unregister

0 Kudos
LucD
Leadership
Leadership

That doesn't really give any further clues.

You might try using the methods directly, similar to Re: Need a script to keep the MAC address when we export the vm to OVF file.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

I have a few windows 2016 vms setup as jump boxes that im attempting to export the vm though.   I have also tested on my windows 10 vm as well.  when i run the command i get the error no matter which machine and vcenter im connected to.

if i use the older jump box (2008) running powercli 5.5 or my old windows 7 vm  the vm exports fine.  I feel like somethings wrong with the powercli install or build.

how do i install an older version of powercli like version 10 ?

0 Kudos
SHamel5575
Enthusiast
Enthusiast

so i tried connecting directly to the host.  and the export is running fine.  so the issue appears to be when connecting to vcenter to pull the vm.   all of our vcenters are 6.50 Build 8815520

0 Kudos
LucD
Leadership
Leadership

Could it be that the TLS version on your vCenter is not configured correctly?

See KB2147469

Or perhaps a connectivity issue with port 902, between the vCenter and the ESXi node? You could use vmkping to check.

Or perhaps a DNS issue?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

remember it works just fine on an older version of powercli (5.5) would any of this still apply?

0 Kudos
LucD
Leadership
Leadership

I wouldn't know.
But if you have the chance, you could try the script I pointed to earlier, that might give us more clues where it goes wrong.

It could also be interesting to do a network trace for a run with 5.5 and compare that to one with 11.2.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

Both servers are only one hop form the vcenter.   they are all on the same switch and theres no firewalling inbetween.

The script you linked says something about having to be connected to a host on 6.5 but i ran it against vcenter as you suggested.

PS D:\script> .\testexport.ps1

Lease timeout 300

Transferring disk-0.vmdk

Exception calling "GetResponse" with "0" argument(s): "The underlying connection was closed: Could not establish trust

relationship for the SSL/TLS secure channel."

At D:\script\testexport.ps1:79 char:9

+         $response = $webRequest.GetResponse()

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

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : WebException

You cannot call a method on a null-valued expression.

At D:\script\testexport.ps1:81 char:9

+         $responseStream = $response.GetResponseStream()

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

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At D:\script\testexport.ps1:89 char:17

+ ...     while (($bytesRead = $responseStream.Read($chunk,0,$bufferSize))) ...

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

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At D:\script\testexport.ps1:121 char:9

+         $responseStream.Close()

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

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

0 Kudos
SHamel5575
Enthusiast
Enthusiast

I figured it out.

I had to install the vCenter trusted root CA certificates on the machine i was running the export from.  They must be installed on the machine with the older powercli.

Thanks for your help.

View solution in original post

0 Kudos
LucD
Leadership
Leadership

You could also try to use the  InvalidCertificateAction ​parameter on the Set-PowerCLIConfiguration cmdlet in that case.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

I had done that already.  It was set to ignore.  That didn't help.

0 Kudos
LucD
Leadership
Leadership

Was it set to Ignore on all Scopes?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

hmm how do you check that?

0 Kudos
LucD
Leadership
Leadership

Do a Get-PowerCLIConfiguration, you should see three lines, one for each scope.
They should all say Ignore (to be on the safe side).


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
SHamel5575
Enthusiast
Enthusiast

Get-PowerCLIConfiguration

Scope    ProxyPolicy     DefaultVIServerMode InvalidCertificateAction  DisplayDeprecationWarnings WebOperationTimeout

                                                                                                  Seconds

-----    -----------     ------------------- ------------------------  -------------------------- -------------------

Session  UseSystemProxy  Multiple            Ignore                    True                       300

User                                         Ignore

AllUsers

0 Kudos
LucD
Leadership
Leadership

That should be ok, since the Session one says Ignore.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos