WMI: Difference between revisions

From WikiWiki
Jump to navigation Jump to search
No edit summary   (change visibility)
No edit summary   (change visibility)
 
(6 intermediate revisions by the same user not shown)
Line 10: Line 10:
| Example || Get all Windows Desktop OS higher then Win7 || select * from Win32_OperatingSystem where (Version like "10.%" or Version >="6.1") and ProductType = "1" ||
| Example || Get all Windows Desktop OS higher then Win7 || select * from Win32_OperatingSystem where (Version like "10.%" or Version >="6.1") and ProductType = "1" ||
|-
|-
| Example || Select all computer not Domain Controller || SELECT * FROM Win32_ComputerSystem Where DomainRole <> 4 AND DomainRole <> 5
| Example || Select all computer not Domain Controller ||
 
* SELECT * FROM Win32_ComputerSystem Where DomainRole <> 4 AND DomainRole <> 5
select * from Win32_OperatingSystem where (ProductType = "3")  || https://technet.microsoft.com/en-us/library/ee198796.aspx
* select * from Win32_OperatingSystem where (ProductType = "3")   
 
||
http://www.nogeekleftbehind.com/2013/09/10/updated-list-of-os-version-queries-for-wmi-filters/
* https://technet.microsoft.com/en-us/library/ee198796.aspx
* http://www.nogeekleftbehind.com/2013/09/10/updated-list-of-os-version-queries-for-wmi-filters/
|-
| Example  || laptops “PCSystemType = 2” and server “ProductType = 3″ or
Windows 2012, Windows 8 “Version LIKE ‘6.2%’” and Enterprise Edition “OperatingSystemSKU = 4″ or Enterprise N or Server Enterprise (evaluation installation) or Enterprise N (evaluation installation) or Windows 2008 R2, Windows 7 “Version LIKE ‘6.1%'” and Enterprise Edition or Enterprise N or Enterprise E or Ultimate or Ultimate N or Ultimate E.
||
Select * from Win32_OperatingSystem WHERE (ProductType = 3) OR (Version LIKE ‘6.2%’ AND (OperatingSystemSKU = 4 OR OperatingSystemSKU = 27 OR OperatingSystemSKU = 72 OR OperatingSystemSKU = 84)) OR (Version LIKE ‘6.1%’ AND (OperatingSystemSKU = 4 OR OperatingSystemSKU = 27 OR OperatingSystemSKU = 70 OR OperatingSystemSKU = 1 OR OperatingSystemSKU = 28 OR OperatingSystemSKU = 71))
|| https://techontip.wordpress.com/tag/operatingsystemsku/  
|-
|-
| Example || Example || Example ||
| example || get windows 7 enterprise || Select * from Win32_OperatingSystem where Version like "6.1%" and ProductType = "1" and OperatingSystemSKU = "4" || example
|}
|}


Line 28: Line 35:
*query
*query
*if result == blank, query failed, if result holds hostname, query succedded
*if result == blank, query failed, if result holds hostname, query succedded
<gallery>
Wbemtest2008r2nondc.png|checking for non-dc on 2008r2 member server
Wbemtest2012r2dc.png|checking for non-dc on 2012r2 dc
</gallery>
{| class="wikitable"
|-
! ProductType !! Exppl
|-
| 1 || client versions
|-
| 2 || server versions of Windows operating as domain controllers
|-
| 3 || server versions of Windows that are not operating as domain controllers
|}
{| class="wikitable"
|-
! PCSystemType !! Exppl
|-
|0 (0x0) || Unspecified
|-
|1 (0x1) || Desktop
|-
|2 (0x2) || Mobile
|-
|3 (0x3) || Workstation
|-
|4 (0x4) || Enterprise Server
|-
|5 (0x5) || Small Office and Home Office (SOHO) Server
|-
|6 (0x6) || Appliance PC
|-
|7 (0x7) || Performance Server
|-
|8 (0x8) || Maximum
|}
{| class="wikitable"
|-
! domain role property value !!description
|-
| 0 || Stand-alone workstation (the computer is not a member of a domain)
|-
| 1 || Member workstation
|-
| 2 || Stand-alone server (the computer is not a member of a domain)
|-
| 3 || Member server
|-
|  4|| Backup domain controller
|-
| 5 || Primary domain controller
|}
https://technet.microsoft.com/en-us/library/ee198796.aspx
{| class="wikitable"
|-
! Version !! Exppl
|-
| 10.0% || Windows 10
|-
| 6.3% || Windows Server 2012 R2 / Windows 8.1
|-
| 6.2% || Windows Server 2012 / Windows 8
|-
| 6.1% || Windows Server 2008 R2 / Windows 7
|-
| 6.0% || Windows Server 2008 / Windows Vista
|-
| 5.2% || Windows Server 2003 / Windows XP
|}
{| class="wikitable"
|-
! Version !! Exppl
|-
|0||An unknown product
|-
|1||Ultimate
|-
|2||Home Basic
|-
|3||Home Premium
|-
|4||Enterprise
|-
|5||Home Basic N
|-
|6||Business
|-
|7||Server Standard
|-
|8||Server Datacenter (full installation)
|-
|9||Windows Small Business Server
|-
|10||Server Enterprise (full installation)
|-
|11||Starter
|-
|12||Server Datacenter (core installation)
|-
|13||Server Standard (core installation)
|-
|14||Server Enterprise (core installation)
|-
|15||Server Enterprise for Itanium-based Systems
|-
|16||Business N
|-
|17||Web Server (full installation)
|-
|18||HPC Edition
|-
|19||Windows Storage Server 2008 R2 Essentials
|-
|20||Storage Server Express
|-
|21||Storage Server Standard
|-
|22||Storage Server Workgroup
|-
|23||Storage Server Enterprise
|-
|24||Windows Server 2008 for Windows Essential Server Solutions
|-
|25||Small Business Server Premium
|-
|26||Home Premium N
|-
|27||Enterprise N
|-
|28||Ultimate N
|-
|29||Web Server (core installation)
|-
|30||Windows Essential Business Server Management Server
|-
|31||Windows Essential Business Server Security Server
|-
|32||Windows Essential Business Server Messaging Server
|-
|33||Server Foundation
|-
|34||Windows Home Server 2011
|-
|35||Windows Server 2008 without Hyper-V for Windows Essential Server Solutions
|-
|36||Server Standard without Hyper-V
|-
|37||Server Datacenter without Hyper-V (full installation)
|-
|38||Server Enterprise without Hyper-V (full installation)
|-
|39||Server Datacenter without Hyper-V (core installation)
|-
|40||Server Standard without Hyper-V (core installation)
|-
|41||Server Enterprise without Hyper-V (core installation)
|-
|42||Microsoft Hyper-V Server
|-
|43||Storage Server Express (core installation)
|-
|44||Storage Server Standard (core installation)
|-
|45||Storage Server Workgroup (core installation)
|-
|46||Storage Server Enterprise (core installation)
|-
|47||Starter N
|-
|48||Professional
|-
|49||Professional N
|-
|50||Windows Small Business Server 2011 Essentials
|-
|51||Server For SB Solutions
|-
|52||Server Solutions Premium
|-
|53||Server Solutions Premium (core installation)
|-
|54||Server For SB Solutions EM
|-
|55||Server For SB Solutions EM
|-
|56||Windows MultiPoint Server
|-
|59||Windows Essential Server Solution Management
|-
|60||Windows Essential Server Solution Additional
|-
|61||Windows Essential Server Solution Management SVC
|-
|62||Windows Essential Server Solution Additional SVC
|-
|63||Small Business Server Premium (core installation)
|-
|64||Server Hyper Core V
|-
|66||Starter E
|-
|67||Home Basic E
|-
|68||Home Premium E
|-
|69||Professional E
|-
|70||Enterprise E
|-
|71||Ultimate E
|-
|72||Server Enterprise (evaluation installation)
|-
|76||Windows MultiPoint Server Standard (full installation)
|-
|77||Windows MultiPoint Server Premium (full installation)
|-
|79||Server Standard (evaluation installation)
|-
|80||Server Datacenter (evaluation installation)
|-
|84||Enterprise N (evaluation installation)
|-
|95||Storage Server Workgroup (evaluation installation)
|-
|96||Storage Server Standard (evaluation installation)
|-
|98||Windows 8 N
|-
|99||Windows 8 China
|-
|100||Windows 8 Single Language
|-
|101||Windows 8
|-
|103||Professional with Media Center
|}

Latest revision as of 12:42, 25 April 2016

Some WMI filters



Header text Header text Header text References
Example Get all Windows Desktop OS higher then Win7 select * from Win32_OperatingSystem where (Version like "10.%" or Version >="6.1") and ProductType = "1"
Example Select all computer not Domain Controller
  • SELECT * FROM Win32_ComputerSystem Where DomainRole <> 4 AND DomainRole <> 5
  • select * from Win32_OperatingSystem where (ProductType = "3")
Example laptops “PCSystemType = 2” and server “ProductType = 3″ or

Windows 2012, Windows 8 “Version LIKE ‘6.2%’” and Enterprise Edition “OperatingSystemSKU = 4″ or Enterprise N or Server Enterprise (evaluation installation) or Enterprise N (evaluation installation) or Windows 2008 R2, Windows 7 “Version LIKE ‘6.1%'” and Enterprise Edition or Enterprise N or Enterprise E or Ultimate or Ultimate N or Ultimate E.

Select * from Win32_OperatingSystem WHERE (ProductType = 3) OR (Version LIKE ‘6.2%’ AND (OperatingSystemSKU = 4 OR OperatingSystemSKU = 27 OR OperatingSystemSKU = 72 OR OperatingSystemSKU = 84)) OR (Version LIKE ‘6.1%’ AND (OperatingSystemSKU = 4 OR OperatingSystemSKU = 27 OR OperatingSystemSKU = 70 OR OperatingSystemSKU = 1 OR OperatingSystemSKU = 28 OR OperatingSystemSKU = 71))

https://techontip.wordpress.com/tag/operatingsystemsku/
example get windows 7 enterprise Select * from Win32_OperatingSystem where Version like "6.1%" and ProductType = "1" and OperatingSystemSKU = "4" example


Manually test WMI

wbemtest

  • open
  • connect
  • query
  • if result == blank, query failed, if result holds hostname, query succedded
ProductType Exppl
1 client versions
2 server versions of Windows operating as domain controllers
3 server versions of Windows that are not operating as domain controllers
PCSystemType Exppl
0 (0x0) Unspecified
1 (0x1) Desktop
2 (0x2) Mobile
3 (0x3) Workstation
4 (0x4) Enterprise Server
5 (0x5) Small Office and Home Office (SOHO) Server
6 (0x6) Appliance PC
7 (0x7) Performance Server
8 (0x8) Maximum
domain role property value description
0 Stand-alone workstation (the computer is not a member of a domain)
1 Member workstation
2 Stand-alone server (the computer is not a member of a domain)
3 Member server
4 Backup domain controller
5 Primary domain controller

https://technet.microsoft.com/en-us/library/ee198796.aspx

Version Exppl
10.0% Windows 10
6.3% Windows Server 2012 R2 / Windows 8.1
6.2% Windows Server 2012 / Windows 8
6.1% Windows Server 2008 R2 / Windows 7
6.0% Windows Server 2008 / Windows Vista
5.2% Windows Server 2003 / Windows XP
Version Exppl
0 An unknown product
1 Ultimate
2 Home Basic
3 Home Premium
4 Enterprise
5 Home Basic N
6 Business
7 Server Standard
8 Server Datacenter (full installation)
9 Windows Small Business Server
10 Server Enterprise (full installation)
11 Starter
12 Server Datacenter (core installation)
13 Server Standard (core installation)
14 Server Enterprise (core installation)
15 Server Enterprise for Itanium-based Systems
16 Business N
17 Web Server (full installation)
18 HPC Edition
19 Windows Storage Server 2008 R2 Essentials
20 Storage Server Express
21 Storage Server Standard
22 Storage Server Workgroup
23 Storage Server Enterprise
24 Windows Server 2008 for Windows Essential Server Solutions
25 Small Business Server Premium
26 Home Premium N
27 Enterprise N
28 Ultimate N
29 Web Server (core installation)
30 Windows Essential Business Server Management Server
31 Windows Essential Business Server Security Server
32 Windows Essential Business Server Messaging Server
33 Server Foundation
34 Windows Home Server 2011
35 Windows Server 2008 without Hyper-V for Windows Essential Server Solutions
36 Server Standard without Hyper-V
37 Server Datacenter without Hyper-V (full installation)
38 Server Enterprise without Hyper-V (full installation)
39 Server Datacenter without Hyper-V (core installation)
40 Server Standard without Hyper-V (core installation)
41 Server Enterprise without Hyper-V (core installation)
42 Microsoft Hyper-V Server
43 Storage Server Express (core installation)
44 Storage Server Standard (core installation)
45 Storage Server Workgroup (core installation)
46 Storage Server Enterprise (core installation)
47 Starter N
48 Professional
49 Professional N
50 Windows Small Business Server 2011 Essentials
51 Server For SB Solutions
52 Server Solutions Premium
53 Server Solutions Premium (core installation)
54 Server For SB Solutions EM
55 Server For SB Solutions EM
56 Windows MultiPoint Server
59 Windows Essential Server Solution Management
60 Windows Essential Server Solution Additional
61 Windows Essential Server Solution Management SVC
62 Windows Essential Server Solution Additional SVC
63 Small Business Server Premium (core installation)
64 Server Hyper Core V
66 Starter E
67 Home Basic E
68 Home Premium E
69 Professional E
70 Enterprise E
71 Ultimate E
72 Server Enterprise (evaluation installation)
76 Windows MultiPoint Server Standard (full installation)
77 Windows MultiPoint Server Premium (full installation)
79 Server Standard (evaluation installation)
80 Server Datacenter (evaluation installation)
84 Enterprise N (evaluation installation)
95 Storage Server Workgroup (evaluation installation)
96 Storage Server Standard (evaluation installation)
98 Windows 8 N
99 Windows 8 China
100 Windows 8 Single Language
101 Windows 8
103 Professional with Media Center