GPO Modeling using Powershell

Routine User 1 Reputation point
2022-11-02T12:29:54.13+00:00

Am using powershell to do GPO Modeling.

$gpmObject = New-Object -ComObject GPMgmt.GPM;  
  
$gpmDomain = $gpmObject.GetDomain('domain.com', 'dc1.domain.com', 0);  
  
$gpmConstants = $gpmObject.GetConstants();  
  
$rsopObject = $gpmObject.GetRSOP($gpmConstants.RSOPmodePlanning,$null,0);  
  
$rsopObject.PlanningDomainController ='dc1.domain.com';  
  
$rsopObject.PlanningComputer ='domain\compName$';  
  
$rsopObject.PlanningUser = 'domain\Administrator';  
  
$rsopObject.planningComputerSOM = 'OU=Domain Controllers,DC=domain,DC=com';  
  
$rsopObject.planningUserSOM = 'CN=Users,DC=lyncforb,DC=local';  
  
$rsopObject.PlanningComputerWMIFilters=@($gpmDomain.GetWmiFilter("MSFT_SomFilter.Domain='domain.com',ID='{11111111-1111-1111-1111-111111111111}'"));  
  
$rsopObject.PlanningFlags=8;	//means setting only RSOP_PLANNING_ASSUME_USER_WQLFILTER_TRUE  
  
$createQueryRes=$rsopObject.CreateQueryResults();  
  
$rsopObject.GenerateReport($gpmConstants.ReportHTML).Result;  

Here I want only one WMI Filter to be true when simulating GPO Modeling.

But seems $rsopObject.PlanningComputerWMIFilters is not taken into account at all, and all WMI filters associated with GPOs are evaluated as false.

If I set RSOP_PLANNING_ASSUME_COMP_WQLFILTER_TRUE and also use $rsopObject.PlanningComputerWMIFilters, all WMI Filters are considered as true in the result html (again without considering WMI filters specified in $rsopObject.PlanningComputerWMIFilters).

How to make $rsopObject.PlanningComputerWMIFilters relevant and I only want WMI filters specified there only to be evaluated as true.

Windows
Windows
A family of Microsoft operating systems that run across personal computers, tablets, laptops, phones, internet of things devices, self-contained mixed reality headsets, large collaboration screens, and other devices.
4,803 questions
0 comments No comments
{count} votes