New-SCSMSubscription
New-SCSMSubscription
Creates a subscription in Service Manager.
構文
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>]
詳細説明
The New-SCSMSubscription cmdlet creates a subscription in Service Manager.
パラメーター
-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.
エイリアス |
なし |
必須? |
true |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
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.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
localhost |
パイプライン入力を許可する |
true (ByValue) |
ワイルドカード文字を許可する |
false |
-Condition<Condition>
Specifies the condition under which the subscription runs. Valid values are:
-- Created
-- Updated
-- Deleted
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
Updated |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
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.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
true (ByValue) |
ワイルドカード文字を許可する |
false |
-Criteria<String>
Specifies the XML criteria which the subscription uses. If both Filter and Criteria are specified, only the Criteria is used.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-Description<String>
Describes the subscription.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-DisplayName<String>
Specifies the display name of the subscription.
エイリアス |
なし |
必須? |
true |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-Enable<Boolean>
Indicates whether this cmdlet enables the subscription.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-GroupQueue<String[]>
Specifies a group or a queue to set a limit on the number of objects that the subscription tracks.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-ManagementPack<ManagementPack>
Specifies the name of the management pack in which the subscription is stored.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
The default management pack |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-PassThru
Specifies the output object that represents the subscription. This output object can be passed to other cmdlets.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-Recipient<EnterpriseManagementObject[]>
Specifies the list of users to whom email is sent.
エイリアス |
なし |
必須? |
true |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-SCSession<Connection[]>
Specifies an object that represents the session to a Service Manager management server.
エイリアス |
なし |
必須? |
false |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
true (ByValue) |
ワイルドカード文字を許可する |
false |
-Template<EmailTemplate>
Specifies the name of an email template.
エイリアス |
なし |
必須? |
true |
位置は? |
named |
既定値 |
なし |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-Confirm
コマンドレットを実行する前に、ユーザーに確認を求めます。
必須? |
false |
位置は? |
named |
既定値 |
false |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
-WhatIf
コマンドレットを実行するとどのような結果になるかを表示します。コマンドレットは実行されません。
必須? |
false |
位置は? |
named |
既定値 |
false |
パイプライン入力を許可する |
false |
ワイルドカード文字を許可する |
false |
<CommonParameters>
このコマンドレットは次の共通パラメーターをサポートします。-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer、-OutVariable.詳細については、以下を参照してください。 about_CommonParameters (https://go.microsoft.com/fwlink/p/?LinkID=113216)。
入力
入力型は、コマンドレットにパイプできるオブジェクトの型です。
None.
You cannot pipe input to this cmdlet.
出力
出力型は、コマンドレットによって生成されるオブジェクトの型です。
None.
This cmdlet does not generate any output.
例
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