How to detect Vista or Server 2008 using WMI
We found ourselves wanting to target a GPO at Vista and Server 2008 machines today, and came up with this WMI query which I thought I would share, it may help someone
For Vista
SELECT Version, ProductType
FROM Win32_OperatingSystem
WHERE Version >= “6.0″ AND ProductType = “1″
For Longhorn Server
SELECT Version, ProductType
FROM Win32_OperatingSystem WHERE
Version >= “6.0″ AND ProductType = “3″
Product Type has three possible values:
|
Value |
Description |
| 1 | Work Station |
| 2 | Domain Controller |
| 3 | Server |
More information can be found at http://msdn.microsoft.com/en-gb/library/aa394239.aspx
Version number can be any of the following
| Version No. | Description |
| 6.0 | Windows Server 2008 |
| 6.0 | Windows Vista |
| 5.2 | Windows Server 2003 R2 |
| 5.2 | Windows Server 2003 |
| 5.1 | Windows XP |
| 5.0 | Windows 2000 |
Sorry no link to a list of versions, if anyone has a link, I would gladly modify the post to include it.
Or you could just use:
select * from Win32_OperatingSystem where Caption like ‘%Vista%
Hope this helps someone