Quantcast
Channel: VMware Communities: Message List
Viewing all articles
Browse latest Browse all 225804

Move VMs in Folders by FolderID

$
0
0

Hello,

 

I am curious if there is a way to move VMs into Folders using the FolderID.

 

Back Story

Reimporting a couple hundred VMs from Datastore migration.  The reimport is working great.  Since the company has a number of sub-level folders with the same name in the same cluster, we need to be sure the VMs go into the correct folder.

 

I have the FolderID that these VMs were in.  It would be excellent if I can just MOVE-VM using the FolderID.  I have tried a few simple scripts and they have failed.

I also reviewed this post: Re: I want to move VMs to a folder name called Linux, but we have multiple folder by the same name in our Datacenter, please provide me PowerCLI Script to move exactly

 

I am assuming that would work in my case, it would be extremely impractical.  I was thinking maybe using a CSV file and with Folder and FolderID, do some sort of IF Statement.... Something like

 

Get-Folder -Name $_.Folder |

     If ($._ParentID -match $_.FolderID) ....

 

Something like that.. I cant get the syntex correct.  Plus not sure how to have it keep looking after second failure.. get it in some sort of loop.

 

Thanks

Boston Tech Guy


Viewing all articles
Browse latest Browse all 225804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>