Reputation: 506
When I run:
Get-CimInstance -Namespace "root/subscription" -Query "Select * from __FilterToConsumerBinding"
...It clearly shows this CimInstance exists:
Consumer : CommandLineEventConsumer (Name = "testConsumer")
CreatorSID : {1, 5, 0, 0...}
DeliverSynchronously : False
DeliveryQoS :
Filter : __EventFilter (Name = "testFilter")
MaintainSecurityContext : False
SlowDownProviders : False
PSComputerName :
However, when I attempt to delete this very same CimInstance:
Remove-CimInstance -Namespace "root/subscription" -Query "Select * from __FilterToConsumerBinding"
I get:
Remove-CimInstance : Not found
At test_ciminstance.ps1:1 char:1
+ Remove-CimInstance -Namespace "root/subscription" -Query "Select * fr ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (__FilterToConsu..., Filter = ...):CimInstance) [Remove-CimInstance], CimException
+ FullyQualifiedErrorId : HRESULT 0x80041002,Microsoft.Management.Infrastructure.CimCmdlets.RemoveCimInstanceCommand
I'm at an absolute loss. Clearly this object still exists, why can't it be deleted and why do I get this error?
I verified that with any of the commands below:
Multiple different ways of querying verify the object exists:
Get-CimInstance -Namespace root\subscription -ClassName __FilterToConsumerBinding
Get-CimInstance -Namespace root\subscription __FilterToConsumerBinding |
Where-Object -FilterScript {$_.Filter.Name -eq 'testFilter'}
But no matter in what way I delete it, I always get ObjectNotFound
. These are some of the ways I've tried to delete it:
Get-CimInstance -Namespace root\subscription __FilterToConsumerBinding |
Where-Object -FilterScript {$_.Filter.Name -eq 'testFilter'} |
Remove-CimInstance
$a = Get-CimInstance -Namespace root\subscription __FilterToConsumerBinding
Remove-CimInstance -InputObject $a[0]
How could this be?
Upvotes: 1
Views: 82