Author Posts

November 1, 2013 at 11:06 pm

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.

November 2, 2013 at 3:40 am

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