Search code examples
powershellvspherepowercli

Moving VM to a folder within DataCenter


There are two datastores within the vcenter I'm working on. In both datastores, I want to have a folder named simply "Test".

I figured that if I ran Move-VM -VM VmName -Destination Test, the VM would be moved to the "Test" folder found within the datastore it resides on. This is proving not to be the case as I'm getting an error for having multiple values for my Destination.

Is there a way to accomplish this without having to move VMs to another datastore or having the two folders in question named differently?

Thanks for your help


Solution

  • The following line worked for what I wanted to do:

    Move-VM -VM $vmObject -Destination  (($vmObject | Get-Datacenter) | Get-Folder -Name "Test" )