In a powershell window I run the following workflow:
workflow foo { Suspend-Workflow; "hello world" | Out-File c:usersweijgerssdesktopfoo.txt }
Then to resume the workflow, I have the following scheduled via task scheduler triggered to run at startup:
Import-Module PSWorkflow
$jobs = Get-Job -state Suspended
$jobs > c:usersweijgerssdesktopzqqfff.txt
$resumedJobs = $jobs | resume-job -wait
$resumedJobs | wait-job
# Task scheduler action: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe -WindowStyle Normal -NoLogo -NoProfile -Command "&'c:usersweijgerssdesktop
esume.ps1'"
The workflow does not get resumed neither at startup, nor if I manually trigger it via Task Scheduler. The contents of zqqfff.txt indicates that the task scheduler activated powershell cannot see the workflow. A regular powershell window can see the workflow when I run Get-Job.
(Both the normal powershell window and the task scheduler powershell instance run as same user.)
I used procmon to see what's going on and I can see from this that when powershell normally vs taskscheduler it's looking at different workflow persistence paths, namely:
C:UsersweijgerssAppDataLocalmicrosoftwindowsPowerShellWFPSdefaultS-1-5-21-3519956147-933941082-741972881-500_EL (a normal powershell window uses this folder)
C:UsersweijgerssAppDataLocalmicrosoftwindowsPowerShellWFPSdefaultS-1-5-21-3519956147-933941082-741972881-500_EL_NI (a task scheduler activated powershell instance uses this folder)
I'm totally stumped. How can I get a task scheduler activated powershell instance to see the same workflows as normal powershell window can?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…