VMware Cloud Community
deensolea
Contributor
Contributor

move multiple vms to sub folders

hi

please help with a script for moving multiple vms to a sub folder within vm folder.

0 Kudos
6 Replies
SupreetK
Commander
Commander

There are PowerCLI cmdlets and scripts to migrate the VM from one datastore to another. To move the VMs to a sub-folder within a VM folder, I don't think it is possible with conventional migration. You have to use the mv (move) command from the ESXi command line and move the required files. Or use the datastore browser to move the files to the required files. Alternatively, WinSCP is also a good option.

Please consider marking this answer as "correct" or "helpful" if you think your questions have been answered.

Cheers,

Supreet

0 Kudos
LucD
Leadership
Leadership

Can you clarify which type of Folder you are referring to?

Is that a Folder in the vSphere environment of type VM and Template, or is that a folder on the Datastore?


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

0 Kudos
deensolea
Contributor
Contributor

hi,

it is a folder within VMs & templates, also this is VSAN cluster.

I have tried simple move command "Move-VM -VM nlamristest2 -Test VMs" but gets

Move-VM : A parameter cannot be found that matches parameter name 'Test'.

At line:1 char:26

+ Move-VM -VM nlamristest3 -Test VMs

0 Kudos
LucD
Leadership
Leadership

Provided Test is a unique VM & Templates folder in your environment, you can do

Move-VM -VM nlamristest3 -InventoryLocation (Get-Folder -Name Test)


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

0 Kudos
deensolea
Contributor
Contributor

getting below error :

Move-VM : A parameter cannot be found that matches parameter name

'InventoryLocation'.

At line:1 char:26

+ Move-VM -VM nlamristest3 -InventoryLocation (Get-Folder -Name DAMCO)

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

    + CategoryInfo          : InvalidArgument: (:) [Move-VM], ParameterBinding

   Exception

    + FullyQualifiedErrorId : NamedParameterNotFound,VMware.VimAutomation.ViCo

   re.Cmdlets.Commands.MoveVM

0 Kudos
LucD
Leadership
Leadership

Looks like you are using an older PowerCLI version.

Can you check? And eventually upgrade?


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

0 Kudos