Suspend-Job issue

This topic contains 1 reply, has 2 voices, and was last updated by  Richard Siddaway 4 years, 1 month ago.

  • Author
    Posts
  • #11167

    Biswajit
    Participant

    I have using below script for Powershell workflow.
    _____________________________________________________
    workflow tam {

    Suspend-Workflow
    Checkpoint-Workflow

    Get-ChildItem c:\windows -include *.avi,*.m4a,*.m4p,*.m4v,*.mobi,*.mov,*.mp3,*.mp4,*.mpeg,*.mpg,*.VOB,*.wav,*.wma,*.wmv -recurse |
    select Directory,FullName,CreationTime,Length |
    Export-Csv biswajit.csv
    }
    ____________________________________________________
    All seems good but when I used "Suspend-Job" command showing "suspending" after that job is "completed". Get the completed status after using the get-job.

  • #11169

    Richard Siddaway
    Moderator

    Problem number one – positional parameters aren't supported in workflows so you need to use -Path on get-childitem and property on select-object

    This will work


    workflow tam {
    Suspend-Workflow
    Checkpoint-Workflow
    Get-ChildItem -Path c:\windows -Include *.avi,*.m4a,*.m4p,*.m4v,*.mobi,*.mov,*.mp3,*.mp4,*.mpeg,*.mpg,*.VOB,*.wav,*.wma,*.wmv -recurse |
    Select-Object -Property Directory,FullName,CreationTime,Length
    }
    tam

    The workflow will suspend. use Resume-Job to restart the workflow. Resume-Job will report the job as still suspended but it has resume – use get-job to verify.

    I recommend you read my series on workflows on the Scripting Guy blog.
    http://blogs.technet.com/b/heyscriptingguy/archive/2013/01/16/powershell-workflows-job-engine.aspx
    explicitly deals with workflows and the job engine. Links to the other articles are provided in that one

You must be logged in to reply to this topic.