This topic contains 2 replies, has 2 voices, and was last updated by
May 30, 2017 at 2:57 pm #71711ParticipantPoints: 24Rank: Member
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".
Click on Enum Classes -recursive and OK. Then double click on "CCM_DeploymentTaskEx1". Click on Instances and it shows two GUIDS that matched what was showing in the logs. We highlight them and click Delete.
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:
$wmiDeployTsk1Obj = Get-WmiObject -Class "CCM_DeploymentTaskEx1" -Namespace "root\ccm\softwareupdates\deploymentagent" -Recurse
With this, I don't seen any instances.
Next I tried this:
$CIMInstance = Get-CimInstance -Class "CCM_DeploymentTaskEx1" -Namespace "root\ccm\softwareupdates\deploymentagent"
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"
May 30, 2017 at 4:07 pm #71713ParticipantPoints: 24Rank: Member
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:
You cannot call a method on a null-valued expression.
At line:2 char:1
But how do I know what I removed and how do I know if I haven't broke something?
May 31, 2017 at 12:55 am #71746ParticipantPoints: 0Rank: Member
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.
The topic ‘SCCM WMI CCM_DeploymentTaskEx1 convert VB to PowerShell’ is closed to new replies.