Start, Cancel or Delete a SCCM Client Operation

In my last post, I demonstrated how to call the InitiateClientOperation method from the SMS_ClientOperation WMI class to run a SCEP Full Scan. However, this call itself is pretty limited for daily administration, as it requires „internal“ information like the CollectionID, ResourceID or some TypeID for the Operation itself. Probably nothing you want to let some service technician deal with.

So I started to put some meat around this call and ended up with a (definitely longer than expected) script that covers the most typical tasks in regards to SCCM Client Operations.

The script called Set-ClientOperation.ps1 can be found on GitHub at It covers three main scenarios:

1. Start a Client Operation

The syntax to start a client operation is pretty simple


The parameter Start expects one of the following values:

  • FullScan
  • QuickScan
  • DownloadDefinition
  • EvaluateSoftwareUpdates
  • RequestComputerPolicy
  • RequestUserPolicy

The purpose of each should be self-explaining.

CollectionID / CollectionName:

Either supply the CollectionID or the Collection name, but not both. If no ResourceID/ResourceName is specified, the operation will be started on all collection members.

If the CollectionID/CollectionName parameter is not specified, the script will assume the built-in „All Systems“ collection (SMS00001). This is particularly helpful if you want to initiate the operation for one or very few devices. Just be aware, that at least one device needs to be specified via RessourceID/ResourceName. Otherwise one would mistakenly iniate this operation on all devices.

ResourceID / ResourceName:

Either supply one or several ResourceIDs or Resource names, but not both.

2. Cancel a Client Operation

The syntax for Cancel is even shorter:

if you want to cancel all Client Operations. Or

if only individual Client Operations shall be cancelled. The OperationID will be returned by the script when a client operation is started.

3. Delete a Client Operation

The syntax is similar to the Cancel operation:

if you want to delete either All or

all Expired/Cancelled Client Operations. Or

if only individual Client Operations shall be deleted. The OperationID will be returned by the script when a client operation is started.

Additional parameters

The script supports a few additional parameters that are common for all of the above

Provider information

On default the script assumes to be executed on the SCCM Site or Provider Server. You can optionally provide the Name of the Provider Server and the Site Code that shall be used.


On default the script executes with the permission of the current user. You can optionally specify different credentials that shall be used to connect to the Provider Server.


To be able to properly test this script supports the standard WhatIf parameter. If supplied, everything will be executed except the final WMI method call.


On default the script doesn’t write any output except the result of the WMI method call which contains the OperationID. Supply the Verbose parameter to get more information on what is being done in the script.


To get more information please run

Final comments

The script requires at least PowerShell Version 3 and System Center Configuration Manager 2012 SP1 or above.

It comes with  a Set-ClientOperation.Tests.ps1 file that uses Pester for Unit testing.

The script is available on GitHub. It’s published unter the MIT License and so provided „AS IS“. Even if it has been thoroughly tested, be sure to properly test it yourself before using in production. I will not be liable for any damage caused.

As always, I appreciate any comments or suggestions. Please feel free to update or extend the script if necessary.

Das könnte Dich auch interessieren...

3 Antworten

  1. Tom sagt:

    Is it possible to use this script during a Task Sequence?

    I am building a TS for building a Golden Image for VDI.
    One of the things you want to do is run a full scan before you make an image of the drive.

    Running your script in the VM shows a missing module named „ConfigMgr“. That sounds like the script will only run on the SCCM server, or a client running the SCCM console?


    • Maik Koster sagt:

      Hi Tom,

      yes, the script requires a custom Module „ConfigMgr“, which is published at Another option is to use the „Standalone“ version of this script which you will find in the folder called „Standalone“ at the same location as the script itself.

      If you are running a task sequence anyway, it might be easier to just call mpcmdrun locally on the computer. There are command line switches for most operations. The script mentioned above would initiate this action by getting back to the ConfigMgr Provider server which then would try to connect back to the client.


  2. Tom sagt:

    For some reason it won’t let me type in the message box when I click „Antworten“.

    I missed that part about the module then. I noticed the Standalone script, but wasn’t sure of the why. Now I do.

    Running mpcmdrun would be my next thing. I was searching for command line running of the scan, and stumbled on your link as one of the first hits.
    Reading your explanation this would be a better choice for me.



Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.