WMI Connection Error to remote machine
Hi - I'm trying to use WMI to query a remote machine and get process information. Locally my program worked great, but the remote connection gives me a ManagementException "user credentials cannot be used for local connections." Here is my code:
using System.Management;
//....
ManagementScope scope = new ManagementScope(new ManagementPath("\\\\xp-remote02"));
scope.Options.user = "mike";
scope.Options.Password= "tike";
scope.Options.Authentication= AuthenticationLevel.PacketPrivacy;
// Formulate the query - SELECT * FROM Win32_Process WHERE Name LIKE "%dev%"
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Process WHERE Name LIKE \"%dev%\"");
//Execute the query
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
//Get the results
ManagementObjectCollection collection = searcher.Get();
//loop and write to console
foreach( ManagementObject mgt in collection)
{
Console.WriteLine(mgt["Name"].ToString());
}
//....
The error points to the row containing searcher.Get(). I'd really appreciate help on this one - thanks.
Re: WMI Connection Error to remote machine
Is it even possible to remote connect or am I just waiting my time? Why do I keep getting that error?...
Re: WMI Connection Error to remote machine
it is obvious in the error message that your computer has no admin rights (policy) to access remote computers' in your network area. checkout with your network admin, he should provide you with the right GPO ;)
Re: WMI Connection Error to remote machine
I have access to the remote machine via remote-desktop-connection (as simple user). Does that mean I can't access it with WMI unless I have admin privileges?