Run Task Sequence from scheduled Task

Welcome Forums General PowerShell Q&A Run Task Sequence from scheduled Task

This topic contains 2 replies, has 2 voices, and was last updated by

9 months, 1 week ago.

  • Author
  • #98301

    Points: 47
    Rank: Member

    Ok, in our environment standard users are blocked from running PowerShell. What I want to do is deploy a windows upgrade via a task sequence in sccm. Then then run a scheduled task to trigger this task sequence every day at login until they have upgraded their system. If I run an admin PowerShell session and run the below code the task sequence runs. But as the users do not have the rights to run PowerShell I cant use this.

    $UI = New-Object -ComObject "UIResource.UIResourceMgr"

    $ProgramID = "*"
    $PackageID = "PACKAGEID"

    $UI.ExecuteProgram($ProgramID, $PackageID, $true)

    If in the scheduled task I try and use ServiceUI.exe -process:explorer.exe "c:\Windows\System32\WindowsPowershell\v1.0\powershell.exe" -Executionpolicy bypass -file "my powershell script" it does not work but ran as an admin account it does. It would appear that UIResource.UIResourceMgr does not like being run in the system context.. Any ideas I can activate a task sequence running as system ?

  • #98331

    Points: 30
    Rank: Member

    Have you tried using PSExec to launch PowerShell in the System context, then try creating the UIResource object as a test?

    You do not necessarily need a scheduled task. You could set up the scheduling in your task sequence deployment to run every every day at X time. Set the rerun behavior to 'Always rerun program' or 'Rerun if failed on previous attempt'. In your task sequence set a condition to only run if OS version < deployed version.

  • #98349

    Points: 47
    Rank: Member

    Matt, thanks for your reply. Unfortunately in our environment we are not allowed to use PSExec, also the way they have decided to deploy the operating system upgrade is to send the upgrade down as an available task sequence, then a week later send another job to the machines that have not upgraded that launches a form on login. They will then have 3 chances to defer this then it kicks off the previous task sequence to upgrade their machine. As I said before the users are blocked from running PowerShell by lumention (Heat), so I have to run it under system context and this is where I get stuck as it appears that running UIResource.UIResourceMgr under system context it does not have visibility of the task sequence that was sent to the machine. The strange thing is we have done this before for packages and applications and it works just not with task sequences

The topic ‘Run Task Sequence from scheduled Task’ is closed to new replies.