Hi!
Try this:
private void queryMethod(string queryString)
{
ManagementScope scope = new ManagementScope("\\\\localhost\\root\\rsop\\Computer");
scope.Connect();
ObjectQuery query = new ObjectQuery(queryString);
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject mgo in queryCollection)
{
textBox1.Text += mgo.Path + "\r\n";
foreach (PropertyData q in mgo.Properties)
{
textBox1.Text += q.Name + " - " + q.Value + "\r\n";
}
textBox1.Text += "================================\r\n";
}
toolStripProgressBar1.Value = 0;
}
And queryString could be any of these:
SELECT * FROM RSOP_GPO
SELECT * FROM RSOP_PolicySetting
SELECT * FROM RSOP_Session
SELECT * FROM RSOP_RegistryPolicySetting
See additional WMI Classes here:
RSoP WMI Classes (Windows)[
^]