New-SCSMWorkflow
Creates a new workflow in Service Manager.
Syntax
Default (Default)
New-SCSMWorkflow
-Class <String>
[-DisplayName] <String>
[-Description <String>]
[-Enable <Boolean>]
[-Event <WorkflowEvent>]
[-ManagementPack <ManagementPack>]
[-Criteria <String>]
[-Template <ManagementPackObjectTemplate>]
[-EnableNotification <Boolean>]
[-Notification <Hashtable[]>]
[-PassThru]
[-SCSession <Connection[]>]
[-ComputerName <String[]>]
[-Credential <PSCredential>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
Description
The New-SCSMWorkflow cmdlet creates a workflow in Service Manager.
Examples
Example 1: Create a workflow for manual activity creation
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
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.
Example 2: Create a workflow for manual activity creation for a user
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
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.
Parameters
-Class
Specifies the name of the class that starts the workflow when it changes. Valid values are:
- Configuration
- Change
- Incident
- ManualActivity
- ReviewActivity
- DeploymentActivity
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ComputerName
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.
Parameter properties
Type: | System.String[] |
Default value: | Localhost |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Parameter properties
Type: | System.Management.Automation.SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | cf |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Credential
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.
Parameter properties
Type: | System.Management.Automation.PSCredential |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Criteria
Specifies an object that represents criteria to restrict the result set.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Description
Specifies a description for the workflow.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-DisplayName
Specifies the name of the workflow to create.
Parameter properties
Type: | System.String |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | 0 |
Mandatory: | True |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Enable
Indicates whether this cmdlet enables or disables the workflow.
Parameter properties
Type: | System.Boolean |
Default value: | True |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-EnableNotification
Indicates whether this cmdlet enables or disables notifications from the workflow.
Parameter properties
Type: | System.Boolean |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Event
Specifies the condition under which the workflow starts. Valid values are:
- Create
- Update
Parameter properties
Type: | Microsoft.EnterpriseManagement.ServiceManager.Sdk.Workflows.WorkflowEvent |
Default value: | Created |
Accepted values: | Create, Update |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-ManagementPack
Specifies the management pack in which to store the workflow. Do not specify a sealed management pack.
Parameter properties
Type: | Microsoft.EnterpriseManagement.Configuration.ManagementPack |
Default value: | The default management pack |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Notification
Specifies a hash table of users and templates to be used for notifications from the workflow.
Parameter properties
Type: | System.Collections.Hashtable[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-PassThru
Indicates that this cmdlet returns the workflow that this cmdlet creates. You can pass this object to other cmdlets.
Parameter properties
Type: | System.Management.Automation.SwitchParameter |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-SCSession
Specifies an object that represents a session to a Service Manager management server.
Parameter properties
Type: | Microsoft.SystemCenter.Core.Connection.Connection[] |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-Template
Specifies the template to be applied to the objects which the workflow affects.
Parameter properties
Type: | Microsoft.EnterpriseManagement.Configuration.ManagementPackObjectTemplate |
Default value: | None |
Supports wildcards: | False |
DontShow: | False |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Parameter properties
Type: | System.Management.Automation.SwitchParameter |
Default value: | False |
Supports wildcards: | False |
DontShow: | False |
Aliases: | wi |
Parameter sets
(All)
Position: | Named |
Mandatory: | False |
Value from pipeline: | False |
Value from pipeline by property name: | False |
Value from remaining arguments: | False |
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
Inputs
None.
You cannot pipe input to this cmdlet.
Outputs
None.
This cmdlet does not generate any output.