VMware Cloud Community
zik
Enthusiast
Enthusiast
Jump to solution

Move-VM bug

I have two datacenters and am running PowerCLI 11.2.0 and vSphere 6.7u1.

When I try moving a VM to a different folder in the same datacenter, this happens:

try {

    Move-VM -VM $vm -InventoryLocation $folder -ErrorAction Stop

} catch {

    $_

    $_.Exception.ExpectedDatacenter

    $_.Exception.InvalidArgumentInternal

}

Move-VM : 4/2/2019 8:10:28 AM Move-VM The operation for the entity "test-vm"

failed with the following message: "The input arguments had entities that did not

belong to the same datacenter."

At line:2 char:5

+     Move-VM -VM (Get-VM "test-vm") `

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

    + CategoryInfo          : NotSpecified: (:) [Move-VM], DatacenterMismatch

    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates

   _OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

Datacenter-datacenter-34666

Entity                       InputDatacenter         LinkedView
------                       ---------------         ----------
HostSystem-host-145951       Datacenter-datacenter-2          
Folder-group-v49412          Datacenter-datacenter-2          
ResourcePool-resgroup-436820 Datacenter-datacenter-2   
Tags (1)
Reply
0 Kudos
1 Solution

Accepted Solutions
zik
Enthusiast
Enthusiast
Jump to solution

The fix will be released in 11.3 at the end of June.

In the meantime, rather than

Move-VM -VM $vmlist -InventoryLocation $folder

I am using

(Get-View -Id $folder.Id).MoveIntoFolder($vmlist.Id)

View solution in original post

Reply
0 Kudos
16 Replies
LucD
Leadership
Leadership
Jump to solution

The code you included does not correspond with the code in the error message.

Are you sure that Get-VM "test-vm" is only returning 1 object?


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

Reply
0 Kudos
zik
Enthusiast
Enthusiast
Jump to solution

Sorry, I was trying to anonymize the text.  Here it is again.  There is only one copy of the VM ziktest.

PS C:\> try {

    Move-VM -VM ziktest -InventoryLocation "VSS" -ErrorAction Stop

}

catch {

    $_

    $_.Exception.ExpectedDatacenter

    $_.Exception.InvalidArgumentInternal

}

Move-VM : 4/2/2019 8:28:10 AM Move-VM The operation for the entity "ziktest"

failed with the following message: "The input arguments had entities that did not

belong to the same datacenter."

At line:2 char:5

+     Move-VM -VM ziktest -InventoryLocation "VSS" -ErrorAction Stop

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

    + CategoryInfo          : NotSpecified: (:) [Move-VM], DatacenterMismatch

    + FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpdates

   _OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

Datacenter-datacenter-34666

Entity                      InputDatacenter         LinkedView

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

HostSystem-host-72401       Datacenter-datacenter-2          

Folder-group-v40219         Datacenter-datacenter-2          

ResourcePool-resgroup-72394 Datacenter-datacenter-2          

PS C:\> get-vm ziktest

Name                 PowerState Num CPUs MemoryGB      

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

ziktest              PoweredOff 1        0.250         

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I can't replicate the issue.
What platform and PS version are you running this on?


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

Reply
0 Kudos
zik
Enthusiast
Enthusiast
Jump to solution

PS C:\> $global:DefaultVIServer | select Name,Version,Build

Name                         Version Build 

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

vss-vcenter.campusad.msu.edu 6.7.0   11727113

PS C:\> get-module -name vmware*

ModuleType Version    Name                                ExportedCommands      

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

Script     6.7.0.1... VMware.DeployAutomation             {Add-DeployRule, Add-...

Script     6.7.0.1... VMware.ImageBuilder                 {Add-EsxSoftwareDepot...

Script     6.7.0.1... VMware.Vim                                                

Script     11.2.0.... VMware.VimAutomation.Cis.Core       {Connect-CisServer, D...

Script     11.0.0.... VMware.VimAutomation.Cloud          {Add-CIDatastore, Con...

Script     11.2.0.... VMware.VimAutomation.Common                               

Script     11.2.0.... VMware.VimAutomation.Core           {Add-PassthroughDevic...

Script     6.5.4.7... VMware.VimAutomation.HA             Get-DrmInfo           

Script     7.6.0.1... VMware.VimAutomation.HorizonView    {Connect-HVServer, Di...

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

Script     10.0.0.... VMware.VimAutomation.PCloud         {Connect-PIServer, Di...

Script     11.2.0.... VMware.VimAutomation.Sdk            {Get-ErrorReport, Get...

Script     11.2.0.... VMware.VimAutomation.Storage        {Add-KeyManagementSer...

Script     11.2.0.... VMware.VimAutomation.Vds            {Add-VDSwitchPhysical...

Script     10.0.0.... VMware.VimAutomation.vROps          {Connect-OMServer, Di...

Script     6.5.1.7... VMware.VumAutomation                {Add-EntityBaseline, ...

PS C:\> $PSVersionTable

Name                           Value                                            

----                           -----                                            

PSVersion                      5.1.17763.316                                    

PSEdition                      Desktop                                          

PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                          

BuildVersion                   10.0.17763.316                                   

CLRVersion                     4.0.30319.42000                                  

WSManStackVersion              3.0                                              

PSRemotingProtocolVersion      2.3                                              

SerializationVersion           1.1.0.1       

Reply
0 Kudos
zik
Enthusiast
Enthusiast
Jump to solution

Could be that it is choosing the first datacenter it finds and that happens to be where your VM is.  Maybe if your VM and folders are on the other datacenter?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I tested both possibilities, both worked.

What platform are you using, Windows 10?


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

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

And I was also able to replicate this issue.

When you have multiple datacenters, the Move-VM cmdlet, by default seems to go for the datacenter where the MoRef has the highest number in the Value part.

If your VM and Folder are located in any of the other datacenters, you get the error.

This is different from what happened in PowerCLI 10.0.0, there this just works.
In the 11.2.0 Change Log there is a "bug fix" mentioned involving Move-VM and the Destination parameter, which might be behind this changed behaviour.

bug2.jpg

Again, I suggest to open a SR.


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

Reply
0 Kudos
zik
Enthusiast
Enthusiast
Jump to solution

SR 19145352404

As the issue is related to PowerCLI, we need assistance from SDK Support to assist further.

But am sorry to inform that on checking with our Customer Support, I came across that you are not entitled SDK Support.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is afaik a misinterpretation of GSS on what kind of support contract is required for actual PowerCLI bugs.
I would contact your TAM and point to that blogpost I mentioned earlier.


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

Reply
0 Kudos
zik
Enthusiast
Enthusiast
Jump to solution

The fix will be released in 11.3 at the end of June.

In the meantime, rather than

Move-VM -VM $vmlist -InventoryLocation $folder

I am using

(Get-View -Id $folder.Id).MoveIntoFolder($vmlist.Id)

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Correction!
This is apparently a vCenter related bug (as we discovered while I was further analysing the issue with someone from the PowerCLI Dev team).
In VCSA 6.7U2 the problem is gone.

I don't know where GSS got the idea or why they made that premature statement.
There will be no fix in the next PowerCLI release (whatever version or date) since it is a vCenter issue that was fixed in the latest vCenter release.


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

Reply
0 Kudos
jesseh
Contributor
Contributor
Jump to solution

I am seeing this same behavior in 6.7U2b, do you have any additional information on the bug?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Afaik, it was fixed in 6.7U3.


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

Reply
0 Kudos
nickdebom
Contributor
Contributor
Jump to solution

We can confirm this is not fixed using 11.3 powercli and vcenter 6.7U3

then again we use external invocation of scripts via winrm which may extrapolate the issue:

using external winrm command:

Result_STDERR: Move-VM : 1/29/2020 9:13:23 AM Move-VM The operation for the entity
"s0ab0b5h" failed with the following message: "The input arguments had
entities that did not belong to the same datacenter."
At D:\SVN\VMware_Scripts\cCenter\Create-VirtualMachine.ps1:652 char:18
+ $global:vm | Move-VM -InventoryLocation $folderTest
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Move-VM], DatacenterMismatch
+ FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpda
tes_OperationFailed,VMware.VimAutomation.ViCore.Cmdlets.Commands.MoveVM

doing it manually:

PS D:\SVN\VMware_Scripts\Maintain_configure_vsan> $vm | Move-VM -InventoryLocation $folderTest

Name                 PowerState Num CPUs MemoryGB      
----                 ---------- -------- --------      
s0ab0b5h             PoweredOn  8        16.000      

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can you try with PowerCLI 11.5.0?


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

Reply
0 Kudos
nickdebom
Contributor
Contributor
Jump to solution

packaging it today, deploying it tommorow, will updated if succeeds

Reply
0 Kudos