VMware Cloud Community
vmsysadmin20111
Enthusiast
Enthusiast
Jump to solution

move-vm is not working as expected with PowerCLI 6.4 or higher when vCenters are in ELM

Hi all,

trying to move a VM to a specific folder. vCenter is 6.5 U2c in ELM with another vCenter (same version).

For some reason move-vm cmdlet is not working correctly - it's not moving VM to a specified folder. If I use the older PowerCLI 6.3 it's moving the VM correctly. So basicaly, old syntax -Destination is working, and the new syntax -InventoryLocation is not. Am I missing something obvious?

For example, with PowerCLI 10, trying to move vm1 from vApps folder to test1 folder - no error messages, but VM is still in the same folder:

PS C:\> get-vm "vm1" | select Folder

Folder
------
vApps


PS C:\> get-folder "test1"

Name                           Type
----                           ----
test1                          VM


PS C:\> move-vm -VM "vm1" -InventoryLocation "test1"

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
vm1                  PoweredOn  1        1.000


PS C:\> get-vm "vm1" | select Folder

Folder
------
vApps

PS C:\> Get-Module VMware.PowerCLI -ListAvailable | ft -AutoSize


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version       Name            ExportedCommands
---------- -------       ----            ----------------
Manifest   6.5.4.7155375 VMware.PowerCLI

Example with PowerCLI 6.3 R1, works fine:

=================================================

PowerCLI C:\> get-vm "vm1" | select Folder

Folder
------
vApps

PowerCLI C:\> move-vm -VM "vm1" -Destination "test1"

Name                 PowerState Num CPUs MemoryGB
----                 ---------- -------- --------
vm1                  PoweredOn  1        1.000


PowerCLI C:\> get-vm "vm1" | select Folder

Folder
------
test1

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

I just had a similar case, see Script error when trying to move vms to their dedicated folders
And yes, the PowerCLI Team filed a bug for this.


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

View solution in original post

0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Since 6.5.4 you have to use the InventoryLocation on the Move-VM cmdlet to select a VM and Template folder.


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

0 Kudos
vmsysadmin20111
Enthusiast
Enthusiast
Jump to solution

I am using -InventoryLocation. See the example provided. There are no errors, but the VM is not moved.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You have to combine InventoryLocation with the Destination parameter.

The Destination tells where the VM should be moved to (ESXi node, cluster, resourcepool).

The InventoryLocation says to which VM and Templates folder the VM will be moved.

See the description, and examples, of both parameters on the online help-page of the Move-VM cmdlet.


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

0 Kudos
vmsysadmin20111
Enthusiast
Enthusiast
Jump to solution

| You have to combine InventoryLocation with the Destination parameter.

I've tried that too:

move-vm -VM $vm -Destination $cluster -InventoryLocation $folder

No errors, but the VM is not moved.

This only happens on vCenter 6.5 that is linked though ELM with another vCenter 6.5. I also tried on a standalone vCenter 6.7, and I can move the VM without any issues by just specifying -InventoryLocation (no -Destination is necessary in this case).

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That is not exactly what I said, if the VM stays within the same cluster, you don't need the Destination parameter.

The InventoryLocation parameter specifies the target VM Folder.

I just did a quick test (but I'm on PowerCLI 11.0.0), and for it seems to work ok.

I used this code

$vm = Get-VM -Name $vmName

$folder = Get-Folder -Name $folderName -Type VM


Move-VM -VM $vm -InventoryLocation $folder -Confirm:$false


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

vmsysadmin20111
Enthusiast
Enthusiast
Jump to solution

Thanks for testing - did you test with vCenter in ELM?

Like I said, it works with a standalone vCenter, but does not work when you have multiple vCenters in ELM.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I'm on vSphere 6.7U1.
So no, not really tested with your exact environment


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

0 Kudos
vmsysadmin20111
Enthusiast
Enthusiast
Jump to solution

Tested move-vm cmdlet from PowerCLI 11 in another ELM environment with three linked vCenters 6.5, and it does not work when trying to move a VM to another folder with -InventoryLocation flag.

I had to specify the host explicitly with -Destination. So "move-vm $vm -Destination $vm.VMHost -Inventorylocation $folder" works as expected. Would be nice if the documentation can be updated to reflect this change in cmdlet behavior. Also, the -Destination parameter must be VMhost, cluster does not work.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

I just had a similar case, see Script error when trying to move vms to their dedicated folders
And yes, the PowerCLI Team filed a bug for this.


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

0 Kudos