WMI Generic Failure when attempting to remove software updates from a SCCM deployment package

StackOverflow https://stackoverflow.com/questions/8012230

  •  21-02-2021
  •  | 
  •  

Question

I'm using SCCM 2007 and Powershell to automate some mundane tasks in my environment. One of these tasks is to remove all expired or superseded updates in all of my deployment packages. I've went over the Microsoft documentation for the SMS_SoftwareUpdatesPackage WMI class and the RemoveContent method you're supposed to use for this function but keep hitting a wall.

Here's the code I'm currently using.

$x = gwmi SMS_SoftwareUpdatesPackage -computer sccm -namespace root\sms\site_unh -filter "PackageID = 'UNH00277'"
$array = @()
$array += 34827
$x.RemoveContent($array,$true)

Pretty simple, right? I've tried so many different combinations of syntax I'm going crazy. The only lead I've been tracking is that maybe my array datatype isn't right. According to the documentation, it's supposed to be a UInt32 Array but that's just a hunch.

Was it helpful?

Solution

The "solution" for this was to simply set $ErrorActionPreference to SilentlyContinue to skip over this failure. After I added that, it successfully removed all of the updates I wanted.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top