Wednesday, September 25, 2013

Pause SCCM Task Sequence with PowerShell

Lately I have found myself adding allot of pauses into Task Sequences for some buggy applications. It seems to be allot more prevalent in SCCM 2012 SP1 and Windows 7 Task Sequences.

Anyhow for whatever reason you need to create a pause in a Task Sequence (Sophos is an application that comes to mind) here is the steps:

1. Create a 'Run Command Line' step in the task sequence.

2. Add the following PowerShell command to the command line field in the new step:
powershell.exe -executionpolicy bypass -command "Start-Sleep -s 120"

Note: -s is used to specify the number of seconds to pause for. -m switch can be used however this is milliseconds NOT minutes :)

Happy Task Sequencing!

2 comments:

  1. What issues have you seen with Sophos that makes you mention it specifically?
    Do you put this pause before or after the application task?

    I ask because I've just added a task to add Sophos and I have problems. Not the Sophos task but the following task that enables BitLocker. My sequence towards the end is: add to domain, restart, install Sophos, enable BitLocker, restart. It fails when enabling BitLocker. I have just moved the Sophos task to after BitLocker and am building it now to see what happens. But I'm wondering if I should install Sophos, pause, then enable BitLocker.

    ReplyDelete
  2. It turns out it had nothing to do with Sophos needing a pause. The 'restart' task just before enabling BitLocker was, for some reason, set to 'The boot image assigned to this task sequence' rather than 'The currently installed default operating system' so that was why it was failing.

    My task sequence has 'Install Sophos', then 'Enable BitLocker', then restart. No pausing necessary.

    ReplyDelete