Get-WmiObject: Access Denied if i use -AsJob

Welcome Forums General PowerShell Q&A Get-WmiObject: Access Denied if i use -AsJob

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

 
Participant
1 week, 5 days ago.

  • Author
    Posts
  • #181689

    Participant
    Topics: 4
    Replies: 6
    Points: 81
    Rank: Member

    when i issue the command:

    get-wmiobject win32_bios -computername remotecomputername -AsJob

    i got the following error on Receive-Job:

    Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
        + CategoryInfo          : InvalidResult: (:) [], UnauthorizedAccessException
        + FullyQualifiedErrorId : JobStateFailed

    i was stuck with 'RPC server unavailable' error and that was a firewall lack of premissions but now i really dont know why
    i got the access denied matter: the user credential are the same (Administrator) and the command without -AsJob parameter works.

    What have I done untill now:

    – double check firewall permissions on both client and servers and tried with firewalls disabled (so it's not a firewall problem)
    – double check for services active and running; since the cmdlets work without -AsJob parameter, the services are not the issues but
    you never know 🙂
    – double check for user Administrator permissions on wmimgmt.msc, Administrator has all permissions granted on both PCs
    – double check for user Administrator permissions on dcomcnfg, Administrator has all permissions granted on both PCs
    – tried command on both directions Computer A -> Computer B and Computer B -> Computer A: they have the same behavior,
    the cmdlet works without -AsJob parameter as I said, but produces the same error when executed as a job

    I already verified that if the same command is used inside an Invoke-Command -AsJob all works fine
    The other commands with the -AsJob parameter work just fine (for example Restart-Computer of Invoke-Command)

    Any suggestion on what to check to make this command function as a powershell job?
    Thanks in advance

  • #181713

    Participant
    Topics: 20
    Replies: 34
    Points: 172
    Helping Hand
    Rank: Participant

    I faced this error recently. Following are some guidance.

    1. Get-wmiobject or gwmi use rpc high ports (49152-65535). Not sure abt your network. If there is any firewall device you should made some config change there for allowing traffic from source to target to communicate though this higend ports. I think asjob parameters is not the issue.

    2. Invoke command works because it uses WinRM for communication. Which is different that RPC.

    3. I hope if you use get-ciminstance or gcim cmdlet, that will also work. Gwmi generally use dcom protocol which use RPC, where as gcim use winrm.

    Check and let us know if it works.

  • #181779

    Participant
    Topics: 4
    Replies: 6
    Points: 81
    Rank: Member

    thank you for the response.
    I already exclude a firewall issue because i have RPC rules with any ports opened and i even tried with both firewall disabled
    The weird thing is that the cmdlet DOES work without -AsJob parameter (with firewalls enabled), but it DO NOT with -AsJob parameter enabled 🙁

    It seems to be a permission issue, but i dont understand why the command works and give me that error solely when used as a job

You must be logged in to reply to this topic.