Suspend-Job issue

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.

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