views:

177

answers:

1

I'm trying to use WMI to pull some information (hard drive usage, etc) off our SQL server from a scheduled task on a different server. Both machines have the same user account with the same password. Unfortunately, whenever I try to run the below code, I get "Access denied".

The below code works when I make the user on the remote box an adminstrator, but I'm not allowed to do that on our production server.

Does anyone have an idea of what permissions need to be on the remote box in order for this to work?

ManagementScope scope = new ManagementScope(@"\\" + machineName + @"\root\cimv2");
scope.Options.Impersonation = ImpersonationLevel.Impersonate;
ObjectQuery objectQuery = new ObjectQuery(query);
using (ManagementObjectSearcher oSearcher = new ManagementObjectSearcher(scope,objectQuery))
{
    foreach (ManagementObject theInstance in oSearcher.Get())
    {
        ...
    }
}
A: 

Ever get an answer to this?