You've successfully subscribed to Florin Loghiade
Great! Next, complete checkout for full access to Florin Loghiade
Welcome back! You've successfully signed in
Success! Your account is fully activated, you now have access to all content.

Quick Tip: Removing SCCM 2012 R2 Expired Client Operations

in

I’ve been doing some work on a System Center Configuration Manager 2012 R2 installation and after a while the Client Operations log was filled with a lot of expired operations that clogged up the view. Needless to say, the GUI doesn’t help us very much with this matter because you cannot select all the entries and delete them instead you have to manually delete them one by one which complicates things when you have 300 or more operations.

With PowerShell you can do that in a very painless manner.

Now there are two ways to do this. The first is by using the SCCM Module and use the Get-CmClientOperation and then invoke the Remove-CMClientOperation cmdlets and the second one is by using WMI.
Those two methods do the same job but via WMI this operation is faster because you don’t have to import the SCCM PowerShell Module and navigate to the Site PSDrive.

If you want to use the SCCM Cmdlets, you first need to import the SCCM PowerShell module by either using the GUI as shown in the screenshot below or by running Import-Module ‘\AdminConsole\bin\ConfigurationManager.psd1′

GUI Way:

SCCM_GUI

PowerShell Way:

SCCM_PowerShell
The difference between the two is that the GUI will open a regular PowerShell prompt and by manually importing the module, you can have an escalated PowerShell prompt.

I for one find it easier to just use WMI and get over with it ?

Here are the two scripts that can help you solve the job:

Foreach($CMOperation in Get-CMClientOperation)
{
    If ($CMOperation.IsExpired -eq 1) 
    {
        Remove-CMClientOperation -Id $CMOperation.ID -Force
    }
}

With the WMI method, you need to input the site code in the form site_SITECODE like site_FL1

#requires -Version 1 -Modules CimCmdlets
Get-CimInstance -namespace 'root\sms\site_' SMS_ClientOperationStatus -Filter IsExpired=1 | ForEach-Object -Process {
    ([cimclass]'root\sms\site_:sms_ClientOperation').DeleteClientOperation($_.ID )  
}