New-SCSMSubscription

New-SCSMSubscription

Creates a subscription in Service Manager.

Sintaxis

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

Descripción detallada

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

Parámetros

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

Alias

ninguno

¿Requerido?

true

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

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.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

localhost

¿Aceptar canalización?

true (ByValue)

¿Aceptar caracteres comodín?

false

-Condition<Condition>

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

-- Created
-- Updated
-- Deleted

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

Updated

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

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.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

true (ByValue)

¿Aceptar caracteres comodín?

false

-Criteria<String>

Specifies the XML criteria which the subscription uses. If both Filter and Criteria are specified, only the Criteria is used.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Description<String>

Describes the subscription.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-DisplayName<String>

Specifies the display name of the subscription.

Alias

ninguno

¿Requerido?

true

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Enable<Boolean>

Indicates whether this cmdlet enables the subscription.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-GroupQueue<String[]>

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

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-ManagementPack<ManagementPack>

Specifies the name of the management pack in which the subscription is stored.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

The default management pack

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-PassThru

Specifies the output object that represents the subscription. This output object can be passed to other cmdlets.

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Recipient<EnterpriseManagementObject[]>

Specifies the list of users to whom email is sent.

Alias

ninguno

¿Requerido?

true

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-SCSession<Connection[]>

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

Alias

ninguno

¿Requerido?

false

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

true (ByValue)

¿Aceptar caracteres comodín?

false

-Template<EmailTemplate>

Specifies the name of an email template.

Alias

ninguno

¿Requerido?

true

¿Posición?

named

Valor predeterminado

ninguno

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-Confirm

Solicita confirmación antes de ejecutar el cmdlet.

¿Requerido?

false

¿Posición?

named

Valor predeterminado

falso

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

-WhatIf

Muestra lo que sucedería si se ejecutara el cmdlet. El cmdlet no se ejecuta.

¿Requerido?

false

¿Posición?

named

Valor predeterminado

falso

¿Aceptar canalización?

false

¿Aceptar caracteres comodín?

false

<CommonParameters>

Este cmdlet admite los siguientes parámetros comunes: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutBuffer y -OutVariable. Para obtener más información, consulte about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216).

Entradas

El tipo de entrada es el tipo de los objetos que se pueden canalizar al cmdlet.

  • None.

    You cannot pipe input to this cmdlet.

Salidas

El tipo de resultado es el tipo de objetos que emite el cmdlet.

  • None.

    This cmdlet does not generate any output.

Ejemplos

Example 1: Create a subscription

This script creates an email template for printer changes. It then uses that template to create a subscription, 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:\> $EmailTemplateArgs = @{
>>  Class = $PrinterClass
>>  Subject = $Message
>>  Body = $Message
>>  ManagementPack = $ManagementPack
>>  Language = $Language
>>  Encoding = $Encoding
>>  DisplayName = "Printer Email Template"
>>  Description = "A template for printer notifications"
>>  }
PS C:\> New-SCSMEmailTemplate @emailTemplateArgs
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:\> $SubscriptionArgs = @{
>>  Class = $PrinterClass
>>  Condition = "Updated"
>>  Recipient = $Recipient
>>  Template = $PrinterTemplate
>>  DisplayName = "Printer update subscription"
>>  }
PS C:\> New-SCSMSubscription @SubscriptionArgs

Example 2: Create an email notification subscription

This 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:\> $SubscriptionArguments = @{
>>  DisplayName = "A printer subscription"
>>  Description = "Changes in the printer location will cause email to be sent"
>>  Class = Get-SCSMClass -Displayname Microsoft.AD.Printer
>>  Condition = "Updated"
>>  Criteria = $Criteria
>>  Template = Get-SCSMEmailTemplate -Displayname StandardEmailTemplate
>>  Recipient = $Recipient
>>  }
PS C:\> New-SCSMSubscription @SubscriptionArguments

Temas relacionados

Get-SCSMClass

Get-SCSMClassInstance

Get-SCSMEmailTemplate

Get-SCSMManagementPack

Get-SCSMSetting

New-SCSMEmailTemplate

Remove-SCSMSubscription

Update-SCSMSubscription