次の方法で共有


New-SCSMWorkflow

New-SCSMWorkflow

Creates a workflow in Service Manager.

Syntax

Parameter Set: Default
New-SCSMWorkflow [-DisplayName] <String> -Class <String> [-ComputerName <String[]> ] [-Credential <PSCredential> ] [-Criteria <String> ] [-Description <String> ] [-Enable <Boolean> ] [-EnableNotification <Boolean> ] [-Event <WorkflowEvent> ] [-ManagementPack <ManagementPack> ] [-Notification <Hashtable[]> ] [-PassThru] [-SCSession <Connection[]> ] [-Template <ManagementPackObjectTemplate> ] [-Confirm] [-WhatIf] [ <CommonParameters>]

Detailed Description

The New-SCSMWorkflow cmdlet creates a workflow in Service Manager.

Parameters

-Class<String>

Specifies the name of the class that starts the workflow when it changes. Valid values are:

-- Configuration
-- Change
-- Incident
-- ManualActivity
-- ReviewActivity
-- DeploymentActivity

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

-Criteria<String>

Specifies an object that represents criteria to restrict the result set.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Description<String>

Specifies a description for the workflow.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-DisplayName<String>

Specifies the name of the workflow to create.

Aliases

none

Required?

true

Position?

1

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Enable<Boolean>

Indicates whether this cmdlet enables or disables the workflow.

Aliases

none

Required?

false

Position?

named

Default Value

True

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-EnableNotification<Boolean>

Indicates whether this cmdlet enables or disables notifications from the workflow.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Event<WorkflowEvent>

Specifies the condition under which the workflow starts. Valid values are:

-- Create
-- Update

Aliases

none

Required?

false

Position?

named

Default Value

Created

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-ManagementPack<ManagementPack>

Specifies the management pack in which to store the workflow. Do not specify a sealed management pack.

Aliases

none

Required?

false

Position?

named

Default Value

The default management pack

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-Notification<Hashtable[]>

Specifies a hash table of users and templates to be used for notifications from the workflow.

Aliases

none

Required?

false

Position?

named

Default Value

none

Accept Pipeline Input?

false

Accept Wildcard Characters?

false

-PassThru

Indicates that this cmdlet returns the workflow that this cmdlet 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 a 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<ManagementPackObjectTemplate>

Specifies the template to be applied to the objects which the workflow affects.

Aliases

none

Required?

false

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 (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 a workflow for manual activity creation

The first command gets a template named DefaultManualActivityTemplate by using the Get-SCSMObjectTemplate cmdlet. The command stores the template in the $Template variable.

The second command creates an array of notifications as hash tables, and stores them in the $Notification variable.

The final command creates a workflow which can be used when a manual activity is created. Because the script specifies no criteria, this workflow applies to any creation of a manual activity.

PS C:\>$Template = Get-SCSMObjectTemplate -Name "DefaultManualActivityTemplate"
PS C:\> $Notification = @{ User = "Reviewers"; Template = Get-SCSMObjectTemplate -Name "AssignedToUserNotificationTemplate" },@{ User = "Affected User"; Template = Get-SCSMObjectTemplate -Name DefaultReviewActivityTemplate }
PS C:\> New-SCSMWorkflow -DisplayName "Manual activity workflow 07" -Class "ManualActivity" -Description "Contoso workflow 07." -Enable $True -Event Create -Notification $Notification -Template $Template

Example 2: Create a workflow for manual activity creation for a user

The first command creates a criteria string defined for the manual activity to select only those manual activities that were created by the user Evan Narvaez. The command stores those criteria in the $CriteriaString variable.

The second command gets the management pack named Workflows by using the Get-SCSMManagementPack cmdlet, and then stores it in the $ManagementPack variable. A subsequent command uses this value to specify where to save the workflow. This must not be a sealed management pack.

The third command gets a template named DefaultManualActivityTemplate by using the Get-SCSMObjectTemplate cmdlet. The command stores the template in the $Template variable.

The fourth command creates an array of notifications as hash tables, and stores them in the $Notification variable.

The final command creates a workflow which can be used when a manual activity is created.

PS C:\>$CriteriaString = @'
>>  <Criteria>
>>   <Expression>
>>    <SimpleExpression>
>>     <ValueExpression>
>>      <Property State="Post">
>>  $Context/$Path[Relationship='System.WorkItem.Library!System.WorkItemCreatedByUser' TypeConstraint='System!System.Domain.User']/Property[Type='System!System.Domain.User']/UserName$
>>      </Property>
>>     </ValueExpression>
>>     <Operator>Equal</Operator>
>>     <ValueExpression>
>>      <Value>Evan Narvaez</Value>
>>     </ValueExpression>
>>    </SimpleExpression>
>>   </Expression>
>>  </Criteria>
>>  '@
PS C:\> $ManagementPack = Get-SCSMManagementPack -Name "Workflows"
PS C:\> $Template = Get-SCSMObjectTemplate -Name "DefaultManualActivityTemplate"
PS C:\> $Notification = @{ User = "Reviewers"; Template = Get-SCSMObjectTemplate -Name AssignedToUserNotificationTemplate },@{ User = "Affected User"; Template = Get-SCSMObjectTemplate -Name DefaultReviewActivityTemplate }
PS C:\> New-SCSMWorkflow -DisplayName "Manual activity workflow 09" -Class "ManualActivity" -Criteria $CriteriaString -Description "Contoso workflow 09." -Enable $False -Event Create -ManagementPack $ManagementPack -Template $Template

Get-SCSMManagementPack

Get-SCSMObjectTemplate

Get-SCSMWorkflow

Remove-SCSMWorkflow

Update-SCSMWorkflow