The following returns true for servers without the Server GUI installed:
WMIC PATH Win32_OptionalFeature WHERE "Caption = 'Microsoft-Windows-Server-Gui-Shell-Package-DisplayName' AND InstallState = 2"
However, my attempt to translate this into a WMI filter...
SELECT * FROM Win32_OptionalFeature WHERE Caption = Microsoft-Windows-Server-Gui-Shell-Package-DisplayName AND InstallState = 2
...failed with:
A syntax error occurred trying to evaluate a query string.
...Which is fairly unhelpful.
What's the failure and why?