c# WMI Select * from RSOP_GPO

  • Thread starter Thread starter GTruter
  • Start date Start date
G

GTruter

Guest
Hi there,

I am trying to get a list of group policy objects applied to a computer. See code below. I get a list of policies but they differ from the RSOP on the actual computer. I need to know how to filter it so that it only lists the policies that are applied.

ManagementScope scope = new ManagementScope(String.Format("\\\\{0}\\root\\RSOP\\Computer", strComputer));
scope.Connect();
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, new ObjectQuery("Select * from RSOP_GPO"));
foreach (ManagementObject queryObj in searcher.Get())
{
if (!(bool)queryObj.GetPropertyValue("AccessDenied"))
{
cbGSIPA.Items.Add((string)queryObj.GetPropertyValue("Name"));
}
}


Thanks, Garth.

Continue reading...
 
Back
Top