Get-CimInstance MS Learn examples does not work

I am reading about Get-CimInstance at Get-CimInstance (CimCmdlets) - PowerShell | Microsoft Learn
My terminal is configured to use PS7, when I run example 5,

$instance = @{
    ClassName = 'Win32_Process'
    Namespace = 'root/cimv2'
    Properties = @{
        Handle = 0
    }
    Key = 'Handle'
    ClientOnly = $true
}

then
$x = New-CimInstance @instance
I get the following error:

New-CimInstance: A parameter cannot be found that matches parameter name ‘Properties’.

I changed poperties y property, it does not error but whatever handle I give it returns the same output

 $instance = @{
    ClassName = 'Win32_Process'
    Namespace = 'root/cimv2'
    Property = @{
        Handle = 10 (tried 1, 2....)
    }
    Key = 'Handle'
    ClientOnly = $true

always output
image

What is your question? It looks like you have found a bug. You may search if it’s already filed. If not you may file a bug report.

handle must be set with the process ID of an existing process.
if not, i get an error :

Get-CimInstance: Not found

I think this example is an other way for -filter parameter. If you try

get-ciminstance -classname win32_process -filter "handle=0"

you get the same result

Thanks, yes it is a bug in the documentation and Christophe you are correct. Once the right handle number is given it worked fine

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.