New-SCSMWorkflow
Creates a new workflow in Service Manager.
Syntax
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
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | System.String[] |
Position: | Named |
Default value: | Localhost |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | System.Management.Automation.SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | 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.
Type: | System.Management.Automation.PSCredential |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Criteria
Specifies an object that represents criteria to restrict the result set.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Description
Specifies a description for the workflow.
Type: | System.String |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DisplayName
Specifies the name of the workflow to create.
Type: | System.String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Enable
Indicates whether this cmdlet enables or disables the workflow.
Type: | System.Boolean |
Position: | Named |
Default value: | True |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-EnableNotification
Indicates whether this cmdlet enables or disables notifications from the workflow.
Type: | System.Boolean |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Event
Specifies the condition under which the workflow starts. Valid values are:
- Create
- Update
Type: | Microsoft.EnterpriseManagement.ServiceManager.Sdk.Workflows.WorkflowEvent |
Accepted values: | Create, Update |
Position: | Named |
Default value: | Created |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ManagementPack
Specifies the management pack in which to store the workflow. Do not specify a sealed management pack.
Type: | Microsoft.EnterpriseManagement.Configuration.ManagementPack |
Position: | Named |
Default value: | The default management pack |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Notification
Specifies a hash table of users and templates to be used for notifications from the workflow.
Type: | System.Collections.Hashtable[] |
Position: | Named |
Default value: | None |
Required: | False |
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.
Type: | System.Management.Automation.SwitchParameter |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-SCSession
Specifies an object that represents a session to a Service Manager management server.
Type: | Microsoft.SystemCenter.Core.Connection.Connection[] |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Template
Specifies the template to be applied to the objects which the workflow affects.
Type: | Microsoft.EnterpriseManagement.Configuration.ManagementPackObjectTemplate |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | System.Management.Automation.SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
Inputs
None.
You cannot pipe input to this cmdlet.
Outputs
None.
This cmdlet does not generate any output.