Script in workflow runs only once
-
Monday, March 12, 2012 7:00 PM
Hi there,
I create a custom management pack using the Authoring Tools. The MP contains workflow with a PowerShell Script.
The problem is the script runs only once after importing MP or restart HealthService service.
There are no any errors in Operations Manager log in event viewer and workflow status tab.I'm noob in Service Manager. Please help me to understand what's wrong.
All Replies
-
Monday, March 12, 2012 11:03 PMModerator
Could you please provide some more information:
What is the criteria to start the workflow?
Could you please provide the PowerShell script?
Is the PowerShell script running from a PowerShell prompt more than once without any issue?
Is the workflow starting more than once (workflow status tab)?
Andreas Baumgarten | H&D International Group
-
Sunday, March 18, 2012 8:35 PM
Thanks for reply, Andreas
I solved the problem.
More information:
The PowerShell script uses SMLets to apply incident template depending on incident class (network, hardware and etc.):
Import-Module SMLets -Force $EnableTemplate = $null $IncidentClass = ($Incident = Get-SCSMObject (Get-SCSMClass System.WorkItem.Incident$)|?{$_.Id -eq $incidentId}).Classification.displayname $IncidentTemplateList = Get-SCSMObjectTemplate|?{$_.DisplayName -match "!IR"} foreach ($IncidentTemplate in $IncidentTemplateList) { if ($IncidentTemplate.DisplayName -match "!IR-$IncidentClass") { $EnableTemplate = $IncidentTemplate break } } if ($EnableTemplate -eq '') {$EnableTemplate = Get-SCSMObjectTemplate|?{$_.DisplayName -match "!IR-DEF"}} $IncidentRequest = Get-SCSMObjectProjection System.WorkItem.Incident.ProjectionType -filter "Id -eq '$incidentId'" Set-SCSMObjectTemplate -Projection $IncidentRequest -Template $EnableTemplatethe script started working properly then I add following command at the end of script:
Remove-Module SMLets
One more question:
The workflow assigns a template to incident depending on incident's class.
The teplate contains:
"support group" is IT-support
"assigned user" is email enabled security groupHow can I create email notification to assigned user?
I created second workflow with email notification with the same trigger as the workflow with script, but both run at the same time and notification sends in a couple of seconds before template with "assigned user" was applyed.I also created second WriteAction with notification in rule in workflow with PowerShell script:
but WriteActions run at the same time too.
Is there way to run workflows or WriteActions sequentially?
- Edited by petr yakushov Sunday, March 18, 2012 8:36 PM
-
Sunday, March 18, 2012 9:02 PMModerator
I would use a second workflow for notification on reassignment.
Maybe this blog post is helpful:
SCSM 2012: Notify Analyst on Incident Reassignment
Andreas Baumgarten | H&D International Group
- Marked As Answer by petr yakushov Wednesday, March 21, 2012 12:06 PM
-
Wednesday, March 21, 2012 12:06 PMHi, Andreas
Thanks for advice and help!
The blog post is helpful. Notifications work fine.

