Author Posts

February 27, 2014 at 2:28 am

Hello everyone

I'm reworking some of my cmdlets to use Get-Cim instead of Get-WMIobject. My issue is

The Get-WmiObject way works.

$TDOCservices = Get-WmiObject -Class win32_service -filter "Name LIKE '%TDOC%'"

The Get-CimInstance way is not working...

$TDOCservices = Get-CimInstance -ClassName win32_service -Filter "Name LIKE '%TDOC%'"

Can any tell me what I'm overlooking or misunderstood?

February 27, 2014 at 3:11 am

Get-CimInstance returns an inert object that doesn't have the WMI class methods available
You will need to run as
Get-CimInstance -ClassName win32_service -Filter “Name LIKE '%TDOC%'” | invoke-cimmethod -methodname Delete

Remember that CIM cmdlets use WSMAN by default to access remote machines

February 27, 2014 at 5:08 am

Thanks Richard
Will read up on the Invoke-cimmethod 🙂