Home Powershell Activity

Run Activity PowerShell == Cannot force run powershell. Status should not be pending or null

Conner_WoodConner_Wood Customer Ninja IT Monkey ✭✭✭✭
Just watched the Cireson PowerShell Activity Webinar and encountered an error when trying to run the following PowerShell Activity:

Task > Run Activity PowerShell == Cannot force run powershell. Status should not be pending or null.



Best Answer

  • Conner_WoodConner_Wood Customer Ninja IT Monkey ✭✭✭✭
    edited April 2017 Answer ✓
    So it appears making a new Service Request with no activities and adding a PowerShell Activity then saving the new SR causes the workflow instance to lock up the Activity.  By ignoring the workflow instance it is then able to proceed successfully.

    While this had nothing to do with the PowerShell script I mine as well post the correct way of taking the parent description and putting it onto the PS Activity itself. 



    Edit: I'm not sure why the workflow instance would fail under these circumstances, perhaps the workflow starts before the ticket is created so the activity errors out... after looking at the Cireson.Powershell.Activity.Workflow.Library.xml I know the criteria for the Run Activity Powershell Inprogress is UpdateInstance with:
    Pre = Not Equal In Progress Or IS NULL
    Post = Equal In Progress
    Maybe there needs to be a check within the code to confirm it can grab the ticket, maybe a loop with a delay to try 5 times.... that'd explain the "System.NullReferenceException: Object reference not set to an instance of an object."

Answers

  • Conner_WoodConner_Wood Customer Ninja IT Monkey ✭✭✭✭
    Also the workflow Instances for Run Activity Powershell Inprogress have all failed with Error Code == 0 and the following message:

    System.NullReferenceException: Object reference not set to an instance of an object.
       at Cireson.Powershell.Activity.Workflow.RunPowershellScript.a(Object A_0, EventArgs A_1)
       at System.Workflow.ComponentModel.Activity.RaiseEvent(DependencyProperty dependencyEvent, Object sender, EventArgs e)
       at System.Workflow.Activities.CodeActivity.Execute(ActivityExecutionContext executionContext)
       at System.Workflow.ComponentModel.ActivityExecutorOperation.Run(IWorkflowCoreRuntime workflowCoreRuntime)
       at System.Workflow.Runtime.Scheduler.Run()

  • Conner_WoodConner_Wood Customer Ninja IT Monkey ✭✭✭✭
    edited April 2017 Answer ✓
    So it appears making a new Service Request with no activities and adding a PowerShell Activity then saving the new SR causes the workflow instance to lock up the Activity.  By ignoring the workflow instance it is then able to proceed successfully.

    While this had nothing to do with the PowerShell script I mine as well post the correct way of taking the parent description and putting it onto the PS Activity itself. 



    Edit: I'm not sure why the workflow instance would fail under these circumstances, perhaps the workflow starts before the ticket is created so the activity errors out... after looking at the Cireson.Powershell.Activity.Workflow.Library.xml I know the criteria for the Run Activity Powershell Inprogress is UpdateInstance with:
    Pre = Not Equal In Progress Or IS NULL
    Post = Equal In Progress
    Maybe there needs to be a check within the code to confirm it can grab the ticket, maybe a loop with a delay to try 5 times.... that'd explain the "System.NullReferenceException: Object reference not set to an instance of an object."

Sign In or Register to comment.