How to migrate VMware VM Templates to another Datastore w/PowerCLi


What’s the problem?

  • There is no direct way to migrate VM Templates from Datastore to Datastore (aka Storage VMotion procedure).

  • Please review available actions for both types of virtual objects.

VM on the left and Template on the right.


Right, Templates have not the «Migrate…» option.

  • There are no PowerCLi cmdlets for this task too.

  • The Move-VM cmdlet does not work with templates, VM only.

Get-Help Move-VM -Online
  • The Move-Template can «move» (register) templates in another VI container, but not actually move to another Datastore.
Get-Help Move-Template -Online


Let me introduce to you my new function Move-Template2Datastore from my PowerCLi Vi-Module module.

The function gets Template object(s) in the pipeline and one target Datastore object and performs three actions in the background:

  • Convert the Template to VM.

  • Migrate the resultant VM (running SVMotion task).

  • Convert the VM back to the Template.

For each Template, you will see three tasks in the «Recent Tasks» pane.


In addition, the migration process visualized by Write-Progress until the end of the migration task.

Get-Template | Move-Template2Datastore (Get-Datastore datastore1)


Returned objects

  • For each Template Move-Template2Datastore returns object with three properties:
Property Description
Template Template name
Datastore Target Datastore name
Error Error message if any error occurred


Migrate Templates to SDRS Cluster

  • Optionally, the function can receive a whole Datastore Cluster and redistribute the Templates across different Datastores within the cluster.
Get-Template | Move-Template2Datastore –DatastoreCluster (Get-DatastoreCluster dscl1)


  • In above example we get two first Windows based Templates that match particular string in their name and migrate them to a Datastore Cluster. As you can see in the returned object’s properties, the Datastore property are not the same!

  • In the second command, we return the same two Templates back to the source Datastore.

Get-Template | Move-Template2Datastore -Datastore (Get-Datastore datastore1)


  • For more details about the function, please take a look at the content based help and examples.
Get-Help Move-Template2Datastore –Examples
Get-Help Move-Template2Datastore –Full
Get-Help Move-Template2Datastore –Parameter Datastore

You may also like:

Test-VMHotfix/Test-VMPing – Check VMware VM for installed Hotfixes
Set-MaxSnapshotNumber – Control maximum number of VMware snapshots
Get-RDM – How to get RDM (Raw Device Mappings) disks
Convert-VmdkThin2EZThick – Convert Thin Provision VMDK disks to Thick

7 thoughts on “How to migrate VMware VM Templates to another Datastore w/PowerCLi

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s