New-SCSMEmailTemplate
New-SCSMEmailTemplate
Creates a new 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 a new Email template for Service Manager.
Parameters
-Body<String>
Provides 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 is running. The user account that is defined 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 to use when connecting to the server on which the System Center Data Access service is running. The provided user account must have access to that server.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
none |
Accept Pipeline Input? |
true (ByValue) |
Accept Wildcard Characters? |
false |
-Description<String>
Provides the descriptive text 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 the Email template will be stored.
Aliases |
none |
Required? |
false |
Position? |
named |
Default Value |
the default management pack |
Accept Pipeline Input? |
false |
Accept Wildcard Characters? |
false |
-PassThru
Returns an object that represents the new Email template. This output object can be passed 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
Sets a flag that 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>
Provides 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, and it represents the language for the message. If this key is not present, a terminating error of category ObjectNotFound is delivered.
Also, if multiple hash tables are provided, if the same Language is used more than one time, a terminating error of category InvalidArgument is delivered. For information see the examples.
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, which can be High, Medium, or 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 --------------------------
This command creates a new Email template which will be applied when a change occurs 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:\>$mp = Get-SCSMManagementPack -name PS ServiceManager.ConfigurationManagement.Configuration
PS C:\>$language = [System.Globalization.CultureInfo]"EN"
PS C:\>$encoding = [System.Text.Encoding]::ASCII
PS C:\>$emailTemplateArgs = @{
>> Class = $printerClass
>> Subject = $message
>> Body = $message
>> ManagementPack = $mp
>> Language = $language
>> Encoding = $encoding
>> DisplayName = "Printer Email Template"
>> Description = "A template for printer notifications"
>> }
PS C:\>New-SCSMEmailTemplate @emailTemplateArgs
-------------------------- EXAMPLE 2 --------------------------
This command creates two new Email templates, one in English and one in German, and which will be triggered when a change occurs to a Windows computer.
PS C:\$Body1 = @'
>> 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:\>$Body2 = @'
>> 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 = $Body1
>> Subject = "This is a notification"
>> Language = [globalization.cultureinfo]"en-us"
>> },@{
>> Body = $Body2
>> Subject = "Benachrichtigungs-Email"
>> Language = [globalization.cultureinfo]"de-de"
>> }
PS C:\>$TemplateArguments = @{
>> DisplayName = “WindowsChangeEmailTemplate”
>> Class = get-SCSMClass –Name Microsoft.Windows.Computer
>> SendAsHtml = $false
>> TemplateCollection = $templates
>> }
PS C:\>New-SCSMEmailTemplate @TemplateArguments