VMware Cloud Community
Cinnistix
Contributor
Contributor

Move-VM folder structure instead of folder name question

I have a script that is being utilized for VM Migrations from one domain to another (not ELM)

There are 2 source VCSA's call it VCSA-A and VCSA-B

There is 1 target VCSA call it VCSA-C

I have one move-VM command that moves a VM from VCSA-A to VCSA-C

I have another move-VM command that gets filled with a folder name from a variable from VCSA-A VM folder name. The issue is the target VCSA is a merge of 2 different source VCSA's so the folder structure is built in a way where there are 2 or more folders with the same name.

EG. VCSA-A/Folder1 and VCSA-B/Folder1 both in VCSA-C. Folder1 is a "duplicate". 

Normally if its just a unique folder move-vm will work fine, but with 2 folders with the same name under different parents is there a way to tell the move-vm cmdlet to specify a folder structure instead of just a folder?

Thanks!

0 Kudos
3 Replies
LucD
Leadership
Leadership

Are you perhaps using a String for the destination folder?
Try using a Folder object instead, i.e. an object returned by get-Folder, and use the Server parameter to point to the correct folder


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

0 Kudos
Cinnistix
Contributor
Contributor

The issue isnt object vs string i dont think. I get that you can use the object ID as a form of identity thus making it unique.

but...

How would VM-A in VCSA-A know to go into VCSA-A/FolderA in VCSA-C instead of VCSA-B/FolderA in VCSA-C? Lets say each VM grouping has its own folder so theres a good 50 or more 2+ duplicate folders to choose from.

Without defining the parent folder as part of the move-vm I don't know how to tell 50 different source folders what their equivalents are in the destination folder without explicitly defining each one with a UID which seems very tedious though doable.

Im trying to convince the client to remove the parent VM folder structure on the target VCSA as it has no bearing when the migration is complete and just have these VM grouping folders under root thus negating the issue but not sure ill be successful in that conversation yet.

0 Kudos
LucD
Leadership
Leadership

When you use Get-Folder with the Server parameter, the returned object is unique and perfectly identifies that desired folder.


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

0 Kudos