views:

2845

answers:

1

Hello,

I've got some troubles with Get-WmiObject and usage of this object.

In case, I'm connecting to remote computer - which is not in AD, but in the internet.

I'm using credentials and I'm able to retrieve list of WMI classes, or object (to be specific, I want to work with Win32_Process) via commands:

$credential = Get-Credential
$class = Get-WmiObject -list -computer "xyz" -credential $credential | Where-Object {$_.Name -eq "Win32_Process" }
$object = Get-WmiObject -class Win32_Process -computer "xyz" -credential $credential

When I change the hostname or credentials, then I got and error of "RPC not available", or unauthorized access. Therefore I assume, that RPC server and retrieving of WMI objects & classes works.

But when I retrieve them, I'm not able to work with them. In any case of trying it (calling method, or Get-Member) it's throwing this error:

"Server RPC není k dispozici. (Výjimka na základě hodnoty HRESULT: 0x800706BA)"
(It's a czech localization of: Server RPC is not available. (Exception based on the value of HRESULT: 0x800706BA)

I haven't found any other example of similar error. I'm using PowerShell 1.0 on Vista Ent. machine. Target machine is Win2003 R2 (Product server will be Win. Serv. 2008 - not tested yet).

I would appreciate any advice. Thank you.

+1  A: 

I got and error of "RPC not available", or unauthorized access. Therefore I assume, that RPC server and retrieving of WMI objects & classes works.

Unfortunately that's not a safe assumption. If you try to connect via WMI to a namespace on non-existent machine, e.g. foo ("\foo\root\cimv2"), you'll get exactly that error:

0x800706BA ("The RPC server is unavailable.")

In addition:

I'm connecting to remote computer - which is not in AD, but in the internet.

Note that WMI over the internet is going to be hard to get working. Even if you can ping the target machine, that does not mean you'll be able to connect to it via WMI. DCOM uses a bunch of ports that firewall, NAT routers, etc. will happily block. If your exact same calls work for a local host but not over the internet, you've got a problem.

If you control the firewalls, you can look into restricting the ports that DCOM uses, and then opening up those ports. If you're just using the wild internet, perhaps you might want to look into setting up a VPN, which I think should eliminate the 'Internet' issue?

Daryn