PowerCLI

 View Only
  • 1.  get-wmiobject and get-ciminstance_powershell

    Posted May 02, 2019 04:32 AM

    Hi Luc,

    can you breifelydescribe whats the difference between

    get-wmiobjectand get-ciminstance  .

    do both of them accpet same     classname  parameters ?



  • 2.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 02, 2019 05:16 AM

    No, the class names largely correspond, the way they are called is different.
    In short, the CIM classes are the base classes defined by the Common Information Model.

    The WMI classes are how MSFT implemented CIM classes.

    You can find a good comparison of both in Should I use CIM or WMI with Windows PowerShell?



  • 3.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 02, 2019 06:52 AM

    thanks Luc,

    As per comparision document  CIM is preffered approach  .

    i checked one of the features for remoting uisng cim and i was expecting my prompt changes to remote server (the way enter-pssession  works)as following output seems to suggest iam connected to remote server. but prompt remains on local computer.



  • 4.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 02, 2019 02:54 PM

    No, that will not change your prompt.

    You save the object returned from the New-CimSession call in a variable.

    On each subsequent call to a Cim cmdlet, you pass that object via the CimSession parameter.



  • 5.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 03, 2019 06:15 AM

    thnaksLuc ,

    i am trying to get some basic information on remote computer using this command .

    i have saved session in $cimobj

    iam trying to find what services are running on remote computer .

    is this the right way of using cimcomand ??

    get-cimclass -ClassName Win32_Service -CimSession $cimobj



  • 6.  RE: get-wmiobject and get-ciminstance_powershell
    Best Answer

    Posted May 03, 2019 06:45 AM

    Something like this

    $session = New-CimSession -ComputerName <ComputerName>

    Get-CimInstance -CimSession $session -ClassName Win32_Service



  • 7.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 03, 2019 07:06 AM

    thnaksLuc .it works .j

    ust thought of asking if all three below works on wsman protocol only and winrm service should be running at remote host.

    enter-pssession

    Get-CimInstance -CimSession $session -ClassName Win32_Service

    and

    invoke-command



  • 8.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 04, 2019 02:34 PM

    In PS v6 you can also set up remoting over SSH.
    See for example SETUP POWERSHELL SSH REMOTING IN POWERSHELL 6



  • 9.  RE: get-wmiobject and get-ciminstance_powershell

    Posted May 16, 2019 06:22 AM

    tx i am checking this.