Export a Package from a VMM Server and Import It to a Similar VMM Server (Script)


Updated: May 13, 2016

Applies To: System Center 2012 R2 Virtual Machine Manager, System Center 2012 - Virtual Machine Manager

You can share service templates between VMM management servers by exporting the template from one VMM management server, and then importing it on another. If the VMM management servers are configured similarly, this process is fairly straightforward, and no mapping is necessary. If your VMM management servers are configured in a dissimilar fashion, you will need to implement package mapping. For more information about importing a package using mapping, see Export a Package from a VMM Server and Import It to a Dissimilar VMM Server by Using Advanced Mapping (Script).

System_CAPS_ICON_note.jpg Note

The script in this topic assumes that you have saved the function from Create a Function that Exports a Package (Script) with the name Export-ServiceTemplate.ps1.


The following script loads and uses the function named Export-ServiceTemplate.ps1 to export the specified service template. It then imports the specified template to a VMM management server that is similar to the one from which the template was exported.

  Description:   This script calls a function to export a service template, then  
                 restores the specified template to a similar but different VMM  
                 management server.  
Param (  
   [String] $ServiceTemplate=$(throw "Please provide the name of a service template."),  
   [String] $Release=$(throw "Please provide a release for the service template."),  
   [String] $Path=$(throw "Please provide a share path."),  
   [String] $VMMServer=$(throw "Please provide the name of a VMM server.")  
# Import the file containing the export function into the Windows PowerShell session.  
. .\Export-ServiceTemplate.ps1  
# Export the service template using the Export-ServiceTemplate function.  
Export-ServiceTemplate -Name $ServiceTemplate -Release $Release -Path $Path -VMMServer $VMMServer  
# Get the template package.  
$RestorePath = "$Path\$ServiceTemplate.$Release.xml"  
$Package = Get-SCTemplatePackage -Path $RestorePath  
# Import the package to a similar VMM management server.  
Import-SCTemplate -VMMServer "VMMServer02.Contoso.com" -TemplatePackage $Package -SettingsIncludePrivate -Overwrite