fabio1975
Commander
Commander

Move VM to folder on vCenter with there are multipe Folders with the same name in different paths

Ciao 

In my script to move VMs across vCenter, I need to allocate my VMs in a specified Folder VM.

I need to use all Path VM Folders because in my destination vSphere infrastructure, I have folders with the same name but the command Move-VM for destination and inventory I suppose uses only a Folder Name and not a complete path folder. 

Any idea?

Fabio 

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

Use my Get-FolderByPath function.


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

Reply
0 Kudos
fabio1975
Commander
Commander

Hi LucD,

ok but can I use the output how inputs to the MOVE-VM command?

Fabio 

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

The function returns a Folder object, which you can use on the Destination or InventoryLocation parameter of the Move-VM cmdlet


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

Reply
0 Kudos
fabio1975
Commander
Commander

Ok, so the script you indicated returns me the name of the folder that I should use in the MOve-VM command.


But my problem is that in the destination vcenter I have multiple folders with the same name (with different paths), and the move-vm command with only the name of the folder as the destination gives an error because it finds multiple folders with the same name on the destination and I don't know which one to use.

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos
LucD
Leadership
Leadership

Did you actually read my reply and the blog post?
That function returns an object, use that object, not the name of the Folder.


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

fabio1975
Commander
Commander

Hi LucD,

I tried the script and it seems to work. I insert the function into my code and test everything.
Sorry, if I doubted your indications... every time your indications are correct :slightly_smiling_face:

Fabio

Visit vmvirtual.blog
If you're satisfied give me a kudos

Reply
0 Kudos