VMware Cloud Community
jsmith77
Contributor
Contributor

Template migration from one datastore to another

Hi all,

   I am in the process of moving virtual infrastructure from one physical site to another.  The sites have a direct connection to each other.  My current task is to move our template repository from storage at the original site to storage at the new site.  The templates are all stored in one datastore that is an NFS share on Netapp storage.  I have already copied this datastore to a datastore in the new site.  My next step is to remove the templates from inventory that are located on the original site and add them into inventory from the new site.  I believe powercli would work great for this and I have loosely listed which commands I am using below.  I need to keep the templates in the folder structure found under the "VMs and Template" inventory view.

  Which would be better, to remove the templates from inventory and add them back in from the new location or adjust the template properties with set-template to point at the new location?

$tm = Get-Template

foreach ($template in $tm)

{

$ofl = $template.folderid   # ofl = original folder location

remove-template and new-template?

or

set-template?

}

Reply
0 Kudos
2 Replies
vNEX
Expert
Expert

Hi,

you can also export your folder structure with these scripts mentioned here:

Re: Export / Import selective Folder structure

Re: Folder migration

and then using Move-Template cmdlet move them to desired folder>

Move-Template -Template <Temnplate name> -Destination <Folder name>

or

with Set-Template cmdlet convert your templates to VMs and  with Move-VM -VM <VM name> -Destination <Folder> cmdlet move VMs to desired folders...

_________________________________________________________________________________________ If you found this or any other answer helpful, please consider to award points. (use Correct or Helpful buttons) Regards, P.
jsmith77
Contributor
Contributor

vNEX,   Thanks for the response.  Along with your response and a change in how we are migrating templates, I have found/created a script that will do the job.

@Anyone else,

   Along with vNex's links, I found the following link helpful.  Creating a move-template function mentioned in the link helped complete a script that will do what I need it to.  Given that there is already a move-template in the current version of power-cli, I renamed the function so that I would not have any conflicts.  I also added a command to change the network adapter.

PowerCLI: Move-Template | ICT-Freak.nl

Reply
0 Kudos