New-SCSMEmailTemplate

New-SCSMEmailTemplate

Creates an email template for Service Manager.

Syntax

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

Detailed Description

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

Parameters

-Body<String>

Specifies the message body, which can include insertion strings.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Class<ManagementPackClass>

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

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ComputerName<String[]>

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.

Aliases

none

Required?

false

Position?

named

Default Value

localhost

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Credential<PSCredential>

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-Description<String>

Specifies a description for the email template.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DisplayName<String>

Specifies the name of the email template.

Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Encoding<Encoding>

Specifies the encoding to be used in the message.

Aliases

none

Required?

false

Position?

named

Default Value

Unicode (UTF-8)

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Language<CultureInfo>

Specifies the language for the message.

Aliases

none

Required?

false

Position?

named

Default Value

English (United States)

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ManagementPack<ManagementPack>

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

Aliases

none

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-SCSession<Connection[]>

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

true (ByValue)

Accept Wildcard Characters?

false

-SendAsHtml

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

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Subject<String>

Specifies the subject for the email message.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-TemplateCollection<Hashtable[]>

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.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Urgency<EmailTemplateUrgency>

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

-- High
-- Medium
-- Low

Aliases

none

Required?

false

Position?

named

Default Value

Medium

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Confirm

Prompts you for confirmation before running the cmdlet.

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-WhatIf

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

Required?

false

Position?

named

Default Value

false

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer, and -OutVariable. For more information, see    about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Inputs

The input type is the type of the objects that you can pipe to the cmdlet.

  • None.

    You cannot pipe input to this cmdlet.

Outputs

The output type is the type of the objects that the cmdlet emits.

  • None.

    This cmdlet does not generate any output.

Examples

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

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.

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

Example 2: Create two templates that use different languages

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.

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

Get-SCSMClass

Get-SCSMEmailTemplate

Get-SCSMManagementPack

Get-SCSMEmailTemplateContent

Remove-SCSMEmailTemplate

Update-SCSMEmailTemplate