Import-SCTemplate

Imports a virtual machine template or service template into the VMM library.

Description

The Import-SCTemplate cmdlet imports a virtual machine template or service template into the System Center Virtual Machine Manager (VMM) library. To export a template out of the library, see Export-SCTemplate.

For more information about Import-SCTemplate, type: "Get-Help Import-SCTemplate -online".

Parameters

TemplatePackage

Required? true
Accept Pipeline Input? true (ByValue)
Position? named
Specifies an exported template package that contains seralized settings of a service or virtual machine template.

AllowUnencryptedTransfer

Required? false
Accept Pipeline Input? false
Position? named
Indicates that network file transfers do not require encryption. Allowing unencrypted network file transfers can improve performance if neither the source host nor the destination host requires encryption. 

Use this parameter to: 
- Allow unencrypted file transfers into, or out of, the library.
- Allow unencrypted file transfers into, out of, or within a host group.

Name

Required? false
Accept Pipeline Input? false
Position? named
Specifies the name of a VMM object.

Overwrite

Required? false
Accept Pipeline Input? false
Position? named
Indicates that an import or export operation will overwrite an existing file with the same name. Or, that an import operation will overwrite an existing virtual machine template or service template object with the same name.

PackageMapping

Required? false
Accept Pipeline Input? false
Position? named
Specifies a package mapping object.

Password

Required? false
Accept Pipeline Input? false
Position? named
Specifies a secure string that contains a password.

Release

Required? false
Accept Pipeline Input? false
Position? named
Specifies a string that describes the release of a library resource. VMM automatically creates a release value for every resource imported into the library. After the resource has been imported, the string can be customized.

SettingsIncludePrivate

Required? false
Accept Pipeline Input? false
Position? named
Indicates that sensitive template settings are included in an import or export operation.

SharePath

Required? false
Accept Pipeline Input? false
Position? named
Specifies a path to a valid library share on an existing library server that uses a Universal Naming Convention (UNC) path. 

Example format: –SharePath "\\LibServer01\LibShare"

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.

Path

Required? true
Accept Pipeline Input? false
Position? named
Specifies the destination path for the operation.

Example formats:
 Local path	 -Path "F:\"
 UNC path		 -Path "\\Library\Templates"
 Volume GUID path -Path "\\?\Volume{4703c1ea-8ae7-11db-b473-00123f7603e3}\"
 VMware ESX path  –Path "[storage1]\MyVMwareFolderForVMs\MyVM.vmx"
 Citrix XenServer path - Path “Local storage[99b6212f-b63d-c676-25f9-d6c460992de7]”

Wildcards are supported for "Get" cmdlets and when you specify the UNC path:

Example format:
 UNC path		 -Path "\\VMHostServer\MyVMs\*VM*"

AllowUnencryptedTransfer

Required? false
Accept Pipeline Input? false
Position? named
Indicates that network file transfers do not require encryption. Allowing unencrypted network file transfers can improve performance if neither the source host nor the destination host requires encryption. 

Use this parameter to: 
- Allow unencrypted file transfers into, or out of, the library.
- Allow unencrypted file transfers into, out of, or within a host group.

Name

Required? false
Accept Pipeline Input? false
Position? named
Specifies the name of a VMM object.

Overwrite

Required? false
Accept Pipeline Input? false
Position? named
Indicates that an import or export operation will overwrite an existing file with the same name. Or, that an import operation will overwrite an existing virtual machine template or service template object with the same name.

PackageMapping

Required? false
Accept Pipeline Input? false
Position? named
Specifies a package mapping object.

Password

Required? false
Accept Pipeline Input? false
Position? named
Specifies a secure string that contains a password.

Release

Required? false
Accept Pipeline Input? false
Position? named
Specifies a string that describes the release of a library resource. VMM automatically creates a release value for every resource imported into the library. After the resource has been imported, the string can be customized.

SettingsIncludePrivate

Required? false
Accept Pipeline Input? false
Position? named
Indicates that sensitive template settings are included in an import or export operation.

SharePath

Required? false
Accept Pipeline Input? false
Position? named
Specifies a path to a valid library share on an existing library server that uses a Universal Naming Convention (UNC) path. 

Example format: –SharePath "\\LibServer01\LibShare"

VMMServer

Required? false
Accept Pipeline Input? true (ByValue)
Position? named
Specifies a VMM server object.

Examples

1: Import a previously exported template package.
PS C:\> $Package = Get-SCTemplatePackage -Path "C:\TemplateExports\ServiceTemplate01.new.xml"
PS C:\> Import-SCTemplate -TemplatePackage $Package -SettingsIncludePrivate
The first command gets the exported template package object at the specified path and stores the object in the $Package variable.

The second command imports the template package object stored in $Package, including all template settings.
2: Import an export package and specify a new name and release for the imported template.
PS C:\> Import-SCTemplate -Path "C:\TemplateExports\ServiceTemplate01.new.xml" -SettingsIncludePrivate -Name "New Service Name" -Release "1.0"
This command imports the specified template export package with all of the template's settings and specifies a new name and release for the imported template.
3. Importing a template that has some/all resources in the exported package while changing mapping
PS C:\> $Mappings = New-SCPackageMapping -Path "C:\TemplateExports\VMTemplate01.xml" -PreferPackageResources
PS C:\> $Mapping = $Mappings | where {$_.PackageID -eq "VHD01.vhd"}
PS C:\> $Resource = Get-SCVirtualHardDisk -Name "VHD01.vhd"
PS C:\> Set-SCPackageMapping -PackageMapping $Mapping -TargetObject $Resource
PS C:\> Set-SCPackageMapping -PackageMapping $Mapping -PackageFile "C:\TemplateExports\Resources\VHD01.vhd"
PS C:\> Import-SCTemplate -Path C:\TemplateExports\VMTemplate01.xml -PackageMapping $Mapping -SharePath "\\LibServer01\Share01"
The first command creates a package mapping object for the package stored at the specified path and then stores the package mapping object in the $Mappings variable.

The second command gets a mapping object by package ID and stores the object in the $Mapping variable.

The third command gets the virtual hard disk object named VHD01 and stores the object in the $Resource variable.

The fourth command binds the mapping stored in $Mapping to the object stored in $Resource (VHD01).

The fifth command sets the package file for the mapping stored in $Mapping.

The last command imports the template at the specified path with the specified mappings (in this case, VHD01 imports to Share01).

See Also