I have recently been drug into the SCCM world and so far, I am less convinced it is the right solution for anything. I had a small group of patches that I needed pushed out to all of our Workstations. This hasn't gone well. It turns out that Window 10 has a "feature" that if it determines that the first patch it is evaluating is not required for that specific version, it doesn't look at the rest of the list.
After many calls with Microsoft, in some circumstances it is required that a GUID in WMI be deleted. They walked me through this manually in Windows Management Instrumentation Tester. First Connect to the namespace "root\ccm\softwareupdates\deploymentagent".
Of course, with over 3000 workstations doing this manually exceeds my “must automate” threshold of 3X's.
I thought someone would have done this in PowerShell already, but so far, I have only been able to find VB scripts.
strComputer = “.” strNamespace = “\Root\CCM\SoftwareUpdates\DeploymentAgent” strInstance = “CCM_DeploymentTaskEx1.nkey=1” Set objSWbemServices = GetObject(“winmgmts:\\” & strComputer & strNamespace) objSWbemServices.Delete strInstance
I need to convert this to PowerShell.
This is as far as I have gotten:
Next I tried this:
With this, I can see the GUID but I don't see any delete method.
PS AB1:\> $CIMInstance = Get-CimInstance -Class "CCM_DeploymentTaskEx1" -Namespace "root\ccm\softwareupdates\deploymentagent"
Someone on Slack asked if I had tried Set or Remove-CimInstance. So I tried this:
$CIMInstance = Get-CimInstance -Class "CCM_DeploymentTaskEx1" -Namespace "root\ccm\softwareupdates\deploymentagent" $CIMInstance.GetCimSessionInstanceId() Remove-CimInstance -InputObject $CIMInstance
Now when I run just the first two lines I get an error:
But how do I know what I removed and how do I know if I haven't broke something?
Your attempts are removing the entire class. To duplicate the vb code via powershell
Get-WmiObject -Class "CCM_DeploymentTaskEx1" -Namespace "root\ccm\softwareupdates\deploymentagent" -Filter "nKey = '1'"|Remove-WmiObject
Calling the get-WmiObject and filtering against the value of nKey will allow you to target just the instances you are after. Hope this helps.
You must be logged in to reply to this topic.