Export (0) Print
Expand All
Collapse the table of content
Expand the table of content
Expand Minimize

New-SCSMSubscription

New-SCSMSubscription

Creates a subscription in Service Manager.

Syntax

Parameter Set: Default
New-SCSMSubscription -Class <ManagementPackClass> -DisplayName <String> -Recipient <EnterpriseManagementObject[]> -Template <EmailTemplate> [-ComputerName <String[]> ] [-Condition <Condition> ] [-Credential <PSCredential> ] [-Criteria <String> ] [-Description <String> ] [-Enable <Boolean> ] [-GroupQueue <String[]> ] [-ManagementPack <ManagementPack> ] [-PassThru] [-SCSession <Connection[]> ] [-Confirm] [-WhatIf] [ <CommonParameters>]




Detailed Description

The New-SCSMSubscription cmdlet creates a subscription in Service Manager.

Parameters

-Class<ManagementPackClass>

Specifies the name of the class that the subscription targets. The specified name must reference the same class that is referenced by the specified email template.


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

-Condition<Condition>

Specifies the condition under which the subscription runs. Valid values are:

-- Created
-- Updated
-- Deleted


Aliases

none

Required?

false

Position?

named

Default Value

Updated

Accept Pipeline Input?

false

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

-Criteria<String>

Specifies the XML criteria which the subscription uses. If both the Filter parameter and the Criteria parameter are specified, this cmdlet uses only Criteria.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Description<String>

Describes the subscription.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DisplayName<String>

Specifies the display name of the subscription.


Aliases

none

Required?

true

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Enable<Boolean>

Indicates whether this cmdlet enables the subscription.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-GroupQueue<String[]>

Specifies a group or a queue to set a limit on the number of objects that the subscription tracks.


Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ManagementPack<ManagementPack>

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


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 subscription 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

-Recipient<EnterpriseManagementObject[]>

Specifies the list of users to whom this subscription sends email.


Aliases

none

Required?

true

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

-Template<EmailTemplate>

Specifies the name of an email template.


Aliases

none

Required?

true

Position?

named

Default Value

none

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 (http://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 a subscription

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

The seventh command gets the email template named Printer Email Template by using the Get-SCSMEmailTemplate cmdlet, and then stores it in the $PrinterTemplate variable.

The eighth command gets the class named Microsoft.AD.User by using Get-SCSMClass, and then stores it in the $UserClass variable.

The ninth command gets an instance of the class in $UserClass that has a name that matches a specified filter by using the Get-SCSMClassInstance cmdlet. The command stores that instance in the $Recipient variable.

The final command creates a subscription that uses the email template, created earlier in the example, which sends an email to the administrator anytime a printer is updated.


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
PS C:\> $PrinterTemplate = Get-SCSMEmailTemplate -DisplayName "Printer Email Template"
PS C:\> $UserClass = Get-SCSMClass -Name "Microsoft.AD.User"
PS C:\> $Recipient = Get-SCSMClassInstance -Class $UserClass -Filter 'UserName -like "%Administrator"'
PS C:\> New-SCSMSubscription -Class $PrinterClass -DisplayName "Printer update subscription" -Recipient $Recipient -Template $PrinterTemplate -Condition Updated

Example 2: Create an email notification subscription

The first command creates a criteria for the subscription, and stores it in the $Criteria variable.

The sencond command gets a class instance for the class named System.User that has a name that matches a specified filter by using the Get-SCSMClassInstance cmdlet. The command stores that instance in the $Recipient variable.

The third command gets the class named Microsoft.AD.Printer by using Get-SCSMClass, and then stores it in the $Class variable.

The fourth command gets the email template named StandardEmailTemplate by using Get-SCSMEmailTemplate, and then stores it in the $Template variable.

The final command creates an email notification subscription that is configured to send email to the domain administrators. The subscription is based on changes in the Printer class, where the location has changed.


PS C:\> $Criteria = @'
>>  <Criteria>
>>  <Expression>
>>  <SimpleExpression>
>>  <ValueExpression>
>>  <Property State="Pre">$Context/Property[Type='Windows!Microsoft.AD.Printer']/Location$</Property>
>>     </ValueExpression>
>>    <Operator>NotEqual</Operator>
>>    <ValueExpression>
>>      <Property State="Post">$Context/Property[Type='Windows!Microsoft.AD.Printer']/Location$</Property>
>>     </ValueExpression>
>>    </SimpleExpression>
>>   </Expression>
>>  </Criteria>
>>  @'
PS C:\> $Recipient = Get-SCSMClassInstance -DisplayName "System.User" -Filter "Name -like 'domain admins'"
PS C:\> $Class = Get-SCSMClass -Displayname "Microsoft.AD.Printer"
PS C:\> $Template = Get-SCSMEmailTemplate -Displayname "StandardEmailTemplate"
PS C:\> New-SCSMSubscription -Class <ManagementPackClass> -DisplayName "A printer subscription" -Recipient $Recipient -Template $Template -Condition Updated -Criteria $Criteria -Description "Changes in the printer location will cause email to be sent"

Related topics

Community Additions

ADD
Show:
© 2016 Microsoft