get-service not recognised after task sequence restart

Brass Contributor

We have a task sequence to update a few applications and install most recent monthly update rollup on our Win 7x64 SP1 endpoints. After update install, the task sequence has a restart step, after the restart we have the following 3 steps:

1.Wait for ccmExec service

2.Hardware inventory

3.Software update scan cycle (last step of the task sequence)


Wait for ccmExec step runs the following command line-


powershell.exe -executionPolicy bypass -command "while(get-service -name ccmExec -errorAction silentlyContinue | where-object {$_.status -ne 'running'}) {start-sleep -seconds 5}


In some instances, the task sequence fails executing this step.

Error recorded in smsts.log: "get-service : The term 'get-service' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again." I


've ensured $env:psModulePath has all the correct locations. Could it be that Powershell is not loaded completely after the restart and the task sequence step is preceding that? Any recommendations on how to approach this issue?

1 Reply

is the start type of your sccm Agent on "delay" ?

can you add the transcript logging to your script - i guess this will help you to see what happen