Remotely change Site Code WMIC SCCM CMD

Below is a quick WMIC CMD line that will change the site assignment of a client remotely. Bare in mind that account you use must have Administrative access to the machine you are targeting.

This version will read from a text file the machines that require the Site Code change. Again though, bare in mind that the account running the command must have Administrative access to the machines in question.

Disable or Enable Sophos Services PowerShell Script

I was working at a clients the other month and was getting frustrated with Sophos interfering with what I was try to accomplish.

Here is a quick script to Disable the Sophos services when needed and then Enable the Sophos services when you have finished. Commands are in the info of the script.

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..

[code language=”powershell”]
foreach ($Machine in get-content c:\temp\Machines.txt) {cmd /c SC \\$Machine query Schedule}
[/code]

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.

[code language=”powershell”]
foreach ($Machine in get-content c:\temp\Machines.txt) {cmd /c SC \\$Machine start Schedule}
[/code]

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

[code language=”powershell”]
foreach ($Machine in get-content c:\temp\Machines.txt) {
Get-Service -Name "Task Scheduler" -ComputerName $Machine | Set-Service -Status Running
}
[/code]

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

 

Copyright 2016 SCCMOG | All Rights Reserved