Remotely Start a Service with a list of Machines

So the other day I was on client site dealing with WES 2009 HP t510 thin clients. Now if anyone has ever dealt with WES 2009 and ConfigMgr (SCCM) then you will know it can be challenging.

Anyway the clients on the machines were failing the client check, this was because the Task Scheduler Service is not started by default in WES 2009. The Client Health check that the SCCM client performs on itself is started from a scheduled task, if that service is not started… Well there is your problem.

I needed a way to start that service on all the clients now without deploying to them as there was a write filter enabled or making a GPO change and rebooting them as users were working and on top, the next Maintenance Window was not for about 8 hours. So I came up with this very simple but highly effective for each loop. Firstly I wanted to double check they were all stopped so..

foreach ($Machine in get-content c:\temp\Machines.txt) {cmd /c SC \\$Machine query Schedule}

The text file must have a machine name per line and I’m sure you’ve noticed I’m using a CMD instead of PowerShell.. WES 2009 need I say more?

Once I was satisfied I changed one switch and hey presto it fired off the start command there and then to each machine.

foreach ($Machine in get-content c:\temp\Machines.txt) {cmd /c SC \\$Machine start Schedule}

For those who are not looking at WES 2009 here is the PowerShell command.

foreach ($Machine in get-content c:\temp\Machines.txt) {
Get-Service -Name "Task Scheduler" -ComputerName $Machine | Set-Service -Status Running
}

I did also change the GPO to auto start the service on the next reboot so I would never have to do it again 🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *