Sergey Nivens - Fotolia

Use PowerShell to export, back up SCVMM service templates

It's getting difficult to keep track of all the service templates in SCVMM. Is there a simple command that enables us to query and export them easily?

SCVMM templates and SCVMM service templates can help deploy production VMs and grouped VMs quickly. They can also redeploy VMs, if there are issues with existing VMs.

If you've configured hundreds of SCVMM templates, it's important to perform regular backups to eliminate the need to reconfigure SCVMM templates. There are three ways to back up SCVMM templates. You can perform a regular backup of the SCVMM database, which takes a backup of SCVMM templates in addition to backing up other SCVMM configurations. However, if you only need to export SCVMM templates, you can either use PowerShell or the SCVMM console.

From the SCVMM console, right-click on a template and then click Export. PowerShell reduces the time it takes to perform export operations for multiple templates. You can use the Export-SCTemplate PowerShell cmdlet to export SCVMM templates.

If you need to query SCVMM service templates using PowerShell, use the Get-SCVMTemplate PowerShell cmdlet, as shown in the command below:

Get-SCVMTemplate –VMServer "VMM1Server.TechTarget.Com"

The above command lists all the SCVMM service templates you've created in SCVMM. To export SCVMM service templates, run Export-SCTemplate, as shown in the command below:

Get-SCServiceTemplate | Export-SCTemplate –Path "E:\AllTemplates\"

This command exports all templates to E:\AllTemplates, including every detail about the service templates. A small PowerShell script can help you export all service templates with their names, as shown in the script below.

$AllTemplatesNow = Get-SCServiceTemplate –Name *

ForEach ($Template in $AllTemplatesNow)

{ Export-SCTemplate –ServiceTemplate $Template –Path “E:\ExportedTemplates\$Template }

When you execute the above script, each SCVMM service template from SCVMM will be exported by its name under C:\ExportedTemplates location.

Next Steps

Get started with these PowerShell cmdlets

Check the health status of Hyper-V with PowerShell

Deploy Hyper-V clusters with SCVMM

Dig Deeper on Microsoft Hyper-V management