Get the WMI queries used in a Group Policy object with PowerShell

You can easily read the Group Policy objects in a domain using PowerShell *(if the Group Policy Management Console feature is installed).

Each Group Policy object can have a WMI filter assigned to them which are actually stored as separate objects.


You can read the WMI filter setting using PowerShell with the following commands

$gpo = Get-GPO "Default Domain Policy";

$gpo.WmiFilter|SELECT *

However this doesn't show the actual WMI queries


Luckily this can be solved easily by calling the GetQueryList() method on the WMI filter itself.

$gpo = Get-GPO "Default Domain Policy";

$gpo.WmiFilter.GetQueryList();



The WmiFilter object is actually a .NET type Microsoft.GroupPolicy.WmiFilter - the methods of which are documented here.

https://learn.microsoft.com/en-us/previous-versions/windows/desktop/wmi_v2/class-library/wmifilter-class-microsoft-grouppolicy



 While you're here -
Why not check out our Group Policy Audit and Documentation Tool?








Comments

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time "Some settings are managed by your organization".

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Windows Server 2019 desktop icons such as My Computer, Windows cannot access the specified device, path, or file.