New-SCSMEmailTemplate

Creates an email template for Service Manager.

Syntax

New-SCSMEmailTemplate [-Body <String>] -Class <ManagementPackClass> [-ComputerName <String[]>] [-Confirm]
 [-Credential <PSCredential>] [-Description <String>] -DisplayName <String> [-Encoding <Encoding>]
 [-Language <CultureInfo>] [-ManagementPack <ManagementPack>] [-PassThru] [-SCSession <Connection[]>]
 [-SendAsHtml] [-Subject <String>] [-TemplateCollection <Hashtable[]>] [-Urgency <EmailTemplateUrgency>]
 [-WhatIf] [<CommonParameters>]

Description

The New-SCSMEmailTemplate cmdlet creates an email template for Service Manager.

Examples

Example 1: Create an email template for a change to a printer

PS C:\>$PrinterClass = Get-SCSMClass -Name "Microsoft.AD.Printer"
PS C:\> $Message = 'Printer $Context/Property[''Type=Windows!Microsoft.AD.Printer'']/PrinterName$ has been updated'
PS C:\> $ManagementPack = Get-SCSMManagementPack -Name "ServiceManager.ConfigurationManagement.Configuration"
PS C:\> $Language = [System.Globalization.CultureInfo]"EN"
PS C:\> $Encoding = [System.Text.Encoding]::ASCII
PS C:\> New-SCSMEmailTemplate -Class $PrinterClass -DisplayName "Printer Email Template" -Body $Message -Description "A template for printer notifications" -Encoding $Encoding -Language $Language -ManagementPack $ManagementPack -Subject $Message

The first command gets a class named Microsoft.AD.Printer by using the Get-SCSMClass cmdlet, and then stores it in the $PrinterClass variable.

The second command creates a message for the email, and stores it in the $Message variable. This example uses the same string as the subject and the body of the email.

The third command gets a management pack in which to save this template by using the Get-SCSMManagementPack cmdlet, and then stores it in the $ManagementPack variable.

The fourth and fifth commands store values for language and encoding in the $Language and $Encoding variables.

The final command creates an email template that applies when a change occurs to a printer. The command uses values that were created in the first five commands.

Example 2: Create two templates that use different languages

PS C:\$BodyEng = @'
>> A change has occurred to the following configuration item: 
>> $Context/Property[Type='System!System.Entity']/DisplayName$ 
>> which is owned by: 
>> $Context/Path[Relationship='System!System.ComputerPrimaryUser'   TypeConstraint='Windows!Microsoft.AD.UserBase']/Property[Type='Windows!Microsoft.AD.UserBase']/DistinguishedName$
>> Please investigate
>> Thank you
>> '@
PS C:\> $BodyGer = @'
>>  Eine Konfigurations ¤nderung erfolgte in
>>  $Context/Property[Type='System!System.Entity']/DisplayName$ 
>>  der im Registrierungscontainer
>>  $Context/Path[Relationship='System!System.ComputerPrimaryUser' TypeConstraint='Windows!Microsoft.AD.UserBase']/Property[Type='Windows!Microsoft.AD.UserBase']/DistinguishedName$
>>  gespeichert ist.
>>  Pr ¼fen Sie bitte nach.
>>  Vielen Dank 
>>  '@
PS C:\> $Templates = @{ Body = $BodyEng; Subject = "Change notification"; Language = [globalization.cultureinfo]"en-us" },@{ Body = $BodyGer; Subject = "Benachrichtigungs-Email"; Language = [globalization.cultureinfo]"de-de" }
PS C:\> $ComputerClass = Get-SCSMClass -Name "Microsoft.Windows.Computer"
PS C:\> New-SCSMEmailTemplate -Class $ComputerClass -DisplayName “WindowsChangeEmailTemplate” -TemplateCollection $Templates

The first command stores text for the body of the email for the English template in the $BodyEng variable.

The second command stores text for the body of the email for the German template in the $BodyGer variable.

The third command creates templates as hash tables that include $BodyEng and $BodyGer, and additional content. The two templates have different values for the Language property.

The fourth command gets a class named Microsoft.Windows.Computer by using Get-SCSMClass, and then stores it in the $ComputerClass variable.

The final command creates two email templates, one in English and one in German. They are triggered when a change occurs to a computer that runs the Windows operating system.

Parameters

-Body

Specifies the message body, which can include insertion strings.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Class

Specifies the name of the class that the email template targets.

Type:ManagementPackClass
Required:True
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-ComputerName

Specifies the name of the computer on which the System Center Data Access service runs. The user account that is specified in the Credential parameter must have access rights to the specified computer.

Type:String[]
Required:False
Position:Named
Default value:Localhost
Accept pipeline input:False
Accept wildcard characters:False
-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False
-Credential

Specifies the credentials that this cmdlet uses to connect to the server on which the System Center Data Access service runs. The specified user account must have access rights to that server.

Type:PSCredential
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Description

Specifies a description for the email template.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-DisplayName

Specifies the name of the email template.

Type:String
Required:True
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Encoding

Specifies the encoding to be used in the message.

Type:Encoding
Required:False
Position:Named
Default value:Unicode (UTF-8)
Accept pipeline input:False
Accept wildcard characters:False
-Language

Specifies the language for the message.

Type:CultureInfo
Required:False
Position:Named
Default value:English (United States)
Accept pipeline input:False
Accept wildcard characters:False
-ManagementPack

Specifies the name of the management pack in which this cmdlet stores the email template.

Type:ManagementPack
Required:False
Position:Named
Default value:The default management pack
Accept pipeline input:False
Accept wildcard characters:False
-PassThru

Indicates that this cmdlet returns the email template that it creates. You can pass this object to other cmdlets.

Type:SwitchParameter
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SCSession

Specifies an object that represents the session to a Service Manager management server.

Type:Connection[]
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-SendAsHtml

Specifies that this cmdlet causes the email to be sent as HTML.

Type:SwitchParameter
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Subject

Specifies the subject for the email message.

Type:String
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-TemplateCollection

Specifies a collection of hash tables which represent the email template. The hash table must have the following keys:

- Body. This is a string which represents the body of the template.

  • Subject. This is a string which represents the subject of the email.
  • Language. This must be of type CultureInfo. It represents the language for the message. If you specify multiple hash tables, you cannot use the same value for Language.

Type:Hashtable[]
Required:False
Position:Named
Default value:None
Accept pipeline input:False
Accept wildcard characters:False
-Urgency

Specifies the urgency of the email message. Valid values are:

- High

  • Medium
  • Low

Type:EmailTemplateUrgency
Parameter Sets:Low, Medium, High
Required:False
Position:Named
Default value:Medium
Accept pipeline input:False
Accept wildcard characters:False
-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Required:False
Position:Named
Default value:False
Accept pipeline input:False
Accept wildcard characters:False

Inputs

None.

You cannot pipe input to this cmdlet.

Outputs

None.

This cmdlet does not generate any output.