Suspend-Job issue

This topic contains 1 reply, has 2 voices, and was last updated by Profile photo of Richard Siddaway Richard Siddaway 3 years, 7 months ago.

  • Author
  • #11167
    Profile photo of Biswajit

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


    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
    Profile photo of Richard Siddaway
    Richard Siddaway

    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 {
    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

    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.
    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.