Today I had to re-run a task sequence which had failed the first time. I figured that it could probably be done with PowerShell. After reading Steve Rauchi’s blog post on how to remove the scheduler history object, I started out trying to accomplish the same thing with PowerShell.

In the Configuration Manager 2012 console, we need to locate what Package ID the task sequence has. The Package ID can be found under Software Library – Operating Systems – Task Sequences in the Package IDcolumn for the task sequence in question. In this case the Package ID was C01000D0. We will locate the instance in WMI by searching for the ScheduleID property.

Let start off with the code to locate the instance in WMI containing the Package ID. Launch PowerShell with administrative rights, and type:

Get-WmiObject -Namespace "root\ccm\scheduler" -Class ccm_scheduler_history | where {$_.ScheduleID -like "*C01000D0*"} | ft ScheduleID

This should give the following results:

ScheduleID
----------
P012000E-C01000D0-6F6BCC28

Now that we have the instance, we need to delete it. Modify the previous command so it looks like:

Get-WmiObject -Namespace "root\ccm\scheduler" -Class ccm_scheduler_history | where {$_.ScheduleID -like "*C01000D0*"} | Remove-WmiObject

The instance should now be deleted. Run the first command again, to verify the ouput is empty. Once that is done, we need to restart the CcmExec service. Run the following command:

Get-Service | where {$_.Name -eq "CCMExec"} | Restart-Service

Once the service has restarted, the task sequence should kick off again automatically.

Nickolaj Andersen
Principal Consultant and Enterprise Mobility MVP. Nickolaj has been in the IT industry for the past 10 years specializing in Enterprise Mobility and Security, Windows deployments and Automation. In 2015 Nickolaj was awarded as PowerShell Hero by the community for his script and tools contributions. Author of ConfigMgr Prerequisites Tool, ConfigMgr OSD FrontEnd, ConfigMgr WebService and a frequent speaker at user groups.

(668)

comments
  • Jim Webb
    Posted at 21:44 May 27, 2014
    Jim Webb
    Reply
    Author

    Awesome tip! Very helpful! Thanks!

    • Nickolaj
      Posted at 17:53 May 29, 2014
      Nickolaj
      Reply
      Author

      Hi Jim,

      Thanks for the kind words! Have you checked out the prerequisites script that I just released? It’s definitely worth checking out.

      Regards,
      Nickolaj

  • Alex
    Posted at 10:31 March 19, 2015
    Alex
    Reply
    Author

    That’s great. Thanks

  • Dennis de Haan
    Posted at 12:52 November 16, 2015
    Dennis de Haan
    Reply
    Author

    I just can’t get it to work 🙁 We’re running SCCM 2012 R2 on a Windows 8.1 workstation.

    Removing the Task sequence ID works, but when i restart the service nothing happens and after a few seconds the Task Sequence ID is available again.

    The Re-run Task Sequence Tool has the same effect 🙁 Any ideas what goes wrong?

    • Jay Gingras
      Posted at 19:46 December 12, 2016
      Jay Gingras
      Reply
      Author

      I’m having the same problem, just comes back right after. Even tried pulling machine from collection, after it was gone from Software centre ran script, all was good, re-add machine to collection, once policy hit machine, it was once again “Installed” and in the WMI as well…

  • Leave a Reply