Lgn
Lgn

Reputation: 10109

WMI query on a Remote Machine in Powershell

I want to run a query (for example CIM_Memory) on a remote computer, in that case it's a virtual machine. I use this code in Powershell:

Get-WmiObject CIM_Memory -ComputerName IPADDRESS -Credential USERNAME

Of course with an actual IP and Username. RemoteAdmin is enabled on both OS (both Win7).

I'm getting this exception:

Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)

Since it's Win7 with the UAC feature, the users get an access token. So there's this registry entry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System\ LocalAccountTokenFilterPolicy

After setting this to 1, still getting the same exception. What could be the problem?

Upvotes: 1

Views: 11679

Answers (4)

js2010
js2010

Reputation: 27516

If you enable psremoting, it looks like get-ciminstance works over wsman as well.

Get-Ciminstance CIM_Memory -ComputerName IPADDRESS

Upvotes: 0

js2010
js2010

Reputation: 27516

I second enable psremoting, then you can use the wsman protocol instead of the dcom protocol, and get-ciminstance instead, or invoke-command.

Upvotes: 0

Elvar
Elvar

Reputation: 454

Highly recommend you enable ps remoting if you can. That way you can tell the target computer to run local wmi calls and report back to you.

WMI has loads of problems when it comes to firewalls, random ports.

Upvotes: 0

David Brabant
David Brabant

Reputation: 43559

Did you read the WMI Troubleshooting section on MSDN? Here is what is said about your error:

0x80070005 – E_ACCESS_DENIED - Access denied by DCOM security.

The user does not have remote access to the computer through DCOM. Typically, DCOM errors occur when connecting to a remote computer with a different operating system version.

Give the user Remote Launch and Remote Activation permissions in dcomcnfg. Right-click My Computer-> Properties Under COM Security, click "Edit Limits" for both sections. Give the user you want remote access, remote launch, and remote activation. Then go to DCOM Config, find "Windows Management Instrumentation", and give the user you want Remote Launch and Remote Activation. For more information, see Connecting Between Different Operating Systems

Upvotes: 0

Related Questions