Looking for Clarification on Scripting Guy! Blog RRS feed

  • General discussion

  • I am trying to understand the following blog:

    My question is when you get to the "Get the owner of the process" part. How would you discover that there is a GetOwner method?

    If i run "Get-CimInstance Win32_Process | GM" i do not see GetOwner method.

    I do see it with the following:

    Get-WmiObject Win32_Process | GM.

    Can methods from wmi be used with CimInstance because it method of wmi class? And how would you know about the method in the first palce?

    Thank you.

    Thursday, November 3, 2016 6:09 PM

All replies

  • With CimInstance you need to call get the methods.

    Get-CimClass win32_process|select -expand CimClassMethods


    Thursday, November 3, 2016 6:52 PM
  • I would recommend looking at the documentation.

    -- Bill Stewart [Bill_Stewart]

    Thursday, November 3, 2016 7:02 PM
  • Thank you for reply.

    Get-CimClass win32_process|select -expand CimClassMethods 

    this does show you GetOwner, but why you cant see it here:

    Get-CimInstance Win32_Process | GM | where  MemberType -eq method

    Clone                     Method
    Dispose                   Method
    Equals                    Method
    GetCimSessionComputerName Method
    GetCimSessionInstanceId   Method
    GetHashCode               Method
    GetObjectData             Method
    GetType                   Method
    ToString                  Method

    Thank you.

    Thursday, November 3, 2016 7:15 PM
  • Because that is how Cim CmdLets work.  CIM and WMI are not interchangeable although they are related.


    Thursday, November 3, 2016 7:16 PM
  •  Get-CimInstance Win32_Process | Invoke-CimMethod -MethodName GetOwner|select domain, user


    Thursday, November 3, 2016 8:13 PM