PowerShell Workflow: Restarting a suspended workflow started from a scheduled task.


so have series of powershell workflows controlled patching using sccm.

if start patching workflow using scheduled task when suspends @ checkpoint i'm looking @ being able resume again job not viewable resume.

having read http://blogs.msdn.com/b/powershell/archive/2013/12/23/automatically-resuming-windows-powershell-workflow-jobs-at-logon.aspx , trying meet requirements there.

below example of sequential patching workflow server 1 patched, suspended , email sent resume workflow patch second server (it's example of suspending , resuming workflow).

i've made scheduled job interactive , run highest privileges, opening console admin , same username task run.

ps c:\windows\system32> get-job

id     name            psjobtypename   state         hasmoredata     location             command
--     ----            -------------   -----         -----------     --------             -------
11     patchsequent... psscheduledjob  completed     true            localhost            import-module iiscomto...


ps c:\windows\system32> get-job | receive-job
8/09/2015 11:14:39 isp-dev-patch1: did not snapshot requested
8/09/2015 11:14:39 isp-dev-patch1: starting maint mode
8/09/2015 11:15:06 isp-dev-patch1 putting maint mode has succeeded
8/09/2015 11:15:06 isp-dev-patch1: starting patching
8/09/2015 11:15:07 isp-dev-patch1: scanning , installing patches
8/09/2015 11:17:09 isp-dev-patch1: monitoring patching
8/09/2015 11:18:11 isp-dev-patch1: finished patching
8/09/2015 11:18:41 isp-dev-patch1: patching complete.

id     name            psjobtypename   state         hasmoredata     location             command
--     ----            -------------   -----         -----------     --------             -------
1      job1            psworkflowjob   suspended     true            localhost            invoke-iipatchsequenti...


ps c:\windows\system32> ipmo psworkflow
ps c:\windows\system32> get-job

id     name            psjobtypename   state         hasmoredata     location             command
--     ----            -------------   -----         -----------     --------             -------
11     patchsequent... psscheduledjob  completed     false           localhost            import-module iiscomto...


ps c:\windows\system32>

i cannot find suspended workflow console, same username, same server, elevated or not elevated.

starting same task console, works fine guess satisfies requirements find suspended workflow.

so question how people reliably find , resume suspended workflow started scheduled task? future build sma , wap environment.

looks worked out.


create scheduled task run highest privileges , create loop workflow session on server , run command job, scheduled task 'action':

powershell.exe -windowstyle normal -nologo -noprofile -command "$ws = new-psworkflowsession -enablenetworkaccess; invoke-command -session $ws {powershellworkflowcommand -asjob}"


i need -enablenetaccess workflow patching remote computers.

once scheduled task run, on same server same creds , elevated powershell console session (ie administrator):

$ws = new-psworkflowsession -enablenetworkaccess

invoke-command -session $ws { get-job }

invoke-command -session $ws { get-job | resume-job}

etc.




Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

Error: 0x80073701 when trying to add Print Services Role in Windows 2012 Standard

Disconnecting from a Windows Server 2012 R2 file sharing session on a Windows 7,8,10 machine

Windows 2016 RDS event 1306 Connection Broker Client failed to redirect the user... Error: NULL