none
List all computers with remote WMI not enabled RRS feed

  • Question

  • Hi,

    I want to check if remote WMI is enabled or not on other computers. If not, then these servers should be listed with state.

    If I run following, I get all OK.

    $Computers = Get-Content "C:\ComputerList.txt"

    Get-WmiObject -Query "select * from win32_service where name='WinRM'" -Computer $Computers |ft -Property PSComputerName,StartMode, State, Status

    PSComputerName StartMode State   Status
    -------------- --------- -----   ------
    CompA      Auto      Running OK
    CompB       Auto      Running OK
    CompC       Auto      Running OK
    CompD       Auto      Running OK
    CompE       Auto      Running OK

    But if the CoputerList.txt has any computer with remote WMI not enabled, I get the error

    Get-WmiObject : The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)
    At line:1 char:1
    + Get-WmiObject -Query "select * from win32_service where name='WinRM'" ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [Get-WmiObject], COMException
        + FullyQualifiedErrorId : GetWMICOMException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    My question:

    how can I get the list all computers on which the WinRM does not enabled or and/or "RPC server is unavailable"?

    Best regards

    Birdal


    • Edited by _Birdal Thursday, October 10, 2019 2:02 PM
    Thursday, October 10, 2019 11:38 AM

All replies

  • Are you testing WinRM or WMI. Your question is not easy to understand.

    To test WinRM, use this command:

    Test-WsMan <remotepc>

    Remote WMI is always enabled but may be blocked by the firewall or may be failing.  There is no direct way to test this.


    \_(ツ)_/

    Thursday, October 10, 2019 1:43 PM
  • You will have to trap the errors with Try/Catch.


    \_(ツ)_/

    Thursday, October 10, 2019 2:17 PM
  • Hi,

    yes, there are many methods to test WinRM.

    But my question totally different. I meant, how I can get these list in which stays on which computer the WinRM is not enabled, such as:

    PSComputerName State               Status
    --------------          -----                 ------
    CompA                  not Running    NOT ENABLED
    CompB                  not Running    NOT ENABLED

    Best regards

    Birdal




    • Edited by _Birdal Thursday, October 10, 2019 2:38 PM
    Thursday, October 10, 2019 2:34 PM
  • Use Try/Catch top capture the error and add it to a custom object in the required field.

    help about_try_catch


    \_(ツ)_/

    Thursday, October 10, 2019 2:49 PM