Requêtes WMI et WQL utiles

Partager

Les requêtes WMI ou WQL dans ConfigMgr permettent de remonter dans une collection par exemple tous les ordinateurs d’un fabricant ou d’un modèle particulier. Dans une séquence tâche d’appliquer un package ou application spécifique à un modèle d’ordinateur, etc.

Dell

Tous les ordinateurs Dell

WMI

SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE "%Dell%"

WQL

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%Dell%'

Modèle Dell en particulier

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%Latitude 5501%"

WQL

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model = "Latitude 5501"

HP

Tous les ordinateurs HP

WMI

SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE "%Hewlett-Packard%" or Manufacturer LIKE "%HP%"

WQL

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%Hewlett-Packard%' or SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%HP%'

Modèle HP en particulier

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%EliteBook 840 G6%"

WQL

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model = "EliteBook 840 G6"

Lenovo

Tous les ordinateurs Lenovo

WMI

SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE "%Lenovo%"

WQL

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%Lenovo%'

Modèle Lenovo en particulier

Attention Lenovo a décidé de ne pas faire comme tout le monde… Il faudra soit le nom du produit, soit le modèle sous forme codée qui peut être trouvé sur le site de Lenovo.

WMI

SELECT * FROM Win32_ComputerSystemProduct WHERE Version LIKE "%ThinkPad W541%"

WQL

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model like "20EGS%"

Microsoft Surface

Tous les ordinateurs Microsoft Surface

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%Surface%"

WQL

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model like = "%Surface%"

Modèle Microsoft Surface en particulier

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%Surface Pro 6%"

WQL

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model like = "%Surface Pro 6%"

Apple

Tous les ordinateurs Apple

WMI

SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE "%Apple%"

WQL

select SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like '%Apple%'

Modèle Apple en particulier

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%MacBookPro16,1%"

WQL

SMS_R_SYSTEM.ResourceID,SMS_R_SYSTEM.ResourceType,SMS_R_SYSTEM.Name,SMS_R_SYSTEM.SMSUniqueIdentifier,SMS_R_SYSTEM.ResourceDomainORWorkgroup,SMS_R_SYSTEM.Client from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceID = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model = "MacBookPro16,1"

Virtualisation

Tous les ordinateurs virtuels

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%Virtual%"

WQL

select * from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model like "%Virtual%"

Hyper-V

WMI

SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE "%Microsoft%" AND Model LIKE "%Virtual Machine%"

WQL

select * from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like "%Microsoft%" and SMS_G_System_COMPUTER_SYSTEM.Model like "%Virtual Machine%"

VMWare

WMI

SELECT * FROM Win32_ComputerSystem WHERE Manufacturer LIKE "%VMware%" AND Model LIKE "%VMware Virtual Platform%"

WQL

select * from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Manufacturer like "%VMWare%" and SMS_G_System_COMPUTER_SYSTEM.Model like "%VMware Virtual Platform%"

VirtualBox

WMI

SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%VirtualBox%"

WQL

select * from SMS_R_System inner join SMS_G_System_COMPUTER_SYSTEM on SMS_G_System_COMPUTER_SYSTEM.ResourceId = SMS_R_System.ResourceId where SMS_G_System_COMPUTER_SYSTEM.Model like "%VirtualBox%"


Partager

Steven Bart

Fondateur de StevenBart.com - Suisse. Je suis dans l'informatique depuis 2001, je travaille en tant qu'architecte poste de travail et m'occupe principalement de l'administration de MEMCM (SCCM), du déploiement en masse de postes de travail et d'applications. En savoir plus sur moi.