windows - Can I create global powershell PSWorkflowJob jobs that all users can see? -


i want write powershell workflow run scripts, reboot , continue execute left off. not when user logs on, when computer reboots (so non-interactively).

the challenge needs run locally. windows makes infuriatingly difficult.

what have done far create workflow runs job (psworkflowjob).

in middle of workflow runs restart-computer -wait switch

then create scheduled task runs @ startup resumes workflow

the problem tasks cannot run @ startup unless store credentials or run local system. don't want pass admin creds @ in script run task local system.

when computer reboots task fires, can't find job because job created local admin.

workflow resume_workflow {      powershell.exe -noninteractive -executionpolicy bypass -file 'c:\somescript.ps1'      restart-computer -wait      powershell.exe -noninteractive -executionpolicy bypass -file 'c:\someotherscript.ps1'  }  $taskname = 'continue_workflow' #pass code directly powershell.exe avoid creating .ps1 file $pscode = @' -noprofile -command "& powershell.exe { import-module psworkflow; resume-job -name new_resume_workflow_job -wait; }" '@  $action = new-scheduledtaskaction -execute 'powershell.exe' -argument $pscode $trigger = new-scheduledtasktrigger -atstartup -randomdelay 00:00:30 $settings = new-scheduledtasksettingsset -compatibility win8 $principal = new-scheduledtaskprincipal -userid system `     -logontype serviceaccount -runlevel highest  $definition = new-scheduledtask -action $action -principal $principal `     -settings $settings -description "run $($taskname) @ startup" `     -trigger $trigger  register-scheduledtask -taskname $taskname -inputobject $definition  # execute workflow ps job (psworkflowjob) resume_workflow -asjob -jobname new_resume_workflow_job 


Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -