Get-wmiobject failing as a job

Welcome Forums General PowerShell Q&A Get-wmiobject failing as a job

This topic contains 2 replies, has 2 voices, and was last updated by

Ben
 
Participant
9 months ago.

  • Author
    Posts
  • #93820
    Ben

    Participant
    Points: 2
    Rank: Member

    Hi Everyone

    Currently in a powershell class, one of the tasks was to run a get-wmiobject as a job.

    Gwmi win32_bios -cn lon-dc1 -asjob

    The error i am getting is "The RPC server is unavailable".

    I have disabled the firewall on the remote computer and the same error comes up.

    If i run the gwmi command without the -asjob this works. If i wrap it in invoke-command this works too but myself and the instructor are unable to understand why it fails when i add -asjob at the end.

    Much appreciated if someone can answer and i can tell my instructor. 🙂

    thanks

    Ben

  • #93850

    Participant
    Points: 226
    Helping Hand
    Rank: Participant

    You don't say what OS version or PoSH version you are using on the host and remote host.

    Well, this comes off as an environmental issue on the target and/or on your host.

    Here are some items to check

    1 – Check that DCOM is enabled on both the host and the target PC.
    Check the following registry value on both computers:
    Key: HKLM\Software\Microsoft\OLE, value: EnableDCOM, should be set to 'Y'

    2 – GPO Computer Configuration\Administrative Templates\Windows Components\WinRM\Client\Trusted Hosts

    3 – Check the following services state, that all need to be running
    COM+ Event System
    Remote Access Auto Connection Manager
    Remote Access Connection Manager
    Remote Procedure Call (RPC)
    Remote Procedure Call (RPC) Locator
    Remote Registry
    Server
    Windows Management Instrumentation
    Windows Management Instrumentation Driver Extensions
    WMI Performance Adapter
    Workstation

    4 – On the remtoe host – disable the Firewall for all profiles
    5 – Make sure the network porfile is set to domain – if domain joined, or private if not.
    6 – Check if IPv4 / Ipv6 is being forced between the two.

    Remember this, there are a fwe commands that don't need / use PSRemtoing.

    Tip: Work Remotely with Windows PowerShell without using Remoting or WinRM

    Some cmdlets have a –ComputerName parameter that lets you work with a remote computer without using Windows PowerShell remoting. This means you can use the cmdlet on any computer that is running Windows PowerShell, even if the computer is not configured for Windows PowerShell remoting. These cmdlets include the following:

    'technet.microsoft.com/en-us/library/ff699046.aspx'

    As noted on this forum and others..

    Get-WmiObject doesn't use PowerShell remoting; it's based on the older DCOM / RPC protocols, which aren't particularly firewall-friendly.

    You have two options:

    â—¦If you're running PowerShell 3.0 on all of your machines, you can use the new CIM cmdlets (such as Get-CimInstance instead of Get-WmiObject), which do use the WinRM port.

    â—¦If you need Get-WmiObject to work, you need to enable both the "Windows Management Instrumentation (DCOM-In)" and "Windows Management Instrumentation (WMI-In)" inbound rules in Windows Firewall. Based on what you've said, it looks like the DCOM-In rule might still be disabled.

    • #93966
      Ben

      Participant
      Points: 2
      Rank: Member

      Many thanks for replying I shall remember to try this next time I encounter the issue.
      The OSes I was using was Windows 10 and Server 2016 with POSH 5.1.

      It just confused us that Gwmi win32_bios -cn lon-dc1 works but when I add -asjob it fails to work.

The topic ‘Get-wmiobject failing as a job’ is closed to new replies.