Export (0) Print
Expand All

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

Updated: November 1, 2013

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

You can export a service template from a VMM management server to another location. For example, in a backup scenario, you can export the service template to a share, and then "restore" the template by importing it to the same VMM management server. Importing a service template to the same VMM management server from which it was imported is fairly straightforward, and no mapping is necessary.

For information about how to import a template to a different, but similar, VMM management server, see Export a Package from a VMM Server and Import It to a Similar VMM Server (Script). For information about how to import a template to a dissimilar VMM management server, see Export a Package from a VMM Server and Import It to a Dissimilar VMM Server by Using Advanced Mapping (Script).

noteNote
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.

Disclaimer

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 the same VMM management server.


# Description:   This script uses a function to export a service template, then 
#                restores the specified service to the same VMM management server.

Param (
   [parameter(Mandatory=$true)]
   [String] $ServiceTemplate=$(throw "Please provide the name of a service template."),

   [parameter(Mandatory=$true)]
   [String] $Release=$(throw "Please provide a release for the service template."),

   [parameter(Mandatory=$true)]
   [String] $Path=$(throw "Please provide a path."),

   [parameter(Mandatory=$true)]
   [String] $VMMServer=$(throw "Please provide the name of a VMM server.")
   )

# Import the export function into the Windows PowerShell session.
. .\Export-ServiceTemplate.ps1

# Export the service template.
Export-ServiceTemplate -Name $ServiceTemplate -Release $Release -Path $Path -VMMServer $VMMServer

# Get the template package and the service template.
$RestorePath = "$Path\$ServiceTemplate.$Release.xml"
$Package = Get-SCTemplatePackage -Path $RestorePath
Import-SCTemplate -TemplatePackage $Package -SettingsIncludePrivate -Overwrite

-----
For additional resources, see Information and Support for System Center 2012.

Tip: Use this query to find online documentation in the TechNet Library for System Center 2012. For instructions and examples, see Search the System Center 2012 Documentation Library.
-----
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft