- How to create a PowerShell alias - Tue, Jul 29 2014
- System Center Updates Publisher – Create a SCUP catalog - Fri, May 23 2014
- System Center Updates Publisher – Third-party patch management - Wed, May 21 2014
Recently I had to use SCCM to deploy a Windows XP image with support for seventeen models. To achieve this aim, a major requirement was to check the target hardware was indeed one of the seventeen models supported before pushing a 6GB image to it.
Briefly, SCCM performs OS deployment by preparing a blank disk, writing an image to the disk and injecting appropriate drivers using a template of commands in sequence. Microsoft cunningly calls this a task-sequence. To provide filtering logic, each step within a task-sequence has an options tab where you can add a WMI query. This allows you to use WMI queries which let you target machines very easily but you need to discover the exact model string for the query to work.
You can find this from the command prompt which a one-line command:
wmic csproduct get name
On a HP desktop this gives “HP Compaq dc7700p Convertible Minitower”.
So that’s the answer, but we need to find the question we have to ask within SCCM to get it. Basic research reveals it to be “SELECT * FROM Win32_ComputerSystem WHERE Model LIKE "%HP Compaq dc7700p%"” (noting the double quotes). So we’re sorted then? Well, not quite. As ever, things are not quite that simple. On HP hardware this works great, but not all machines are equal. On the Lenovo I am writing this article the query gives me the result “name 4334”.
Now more experienced readers will note my deliberate mistake. The correct wmic command to get the machine name is not “name” at all, but “version” as you can see in figure 1. This led me to realise that results vary:
Using wmic to find a machine’s model name
depending on both the hardware you have, the operating system you need to target and the content of WMI. For example, another surprising quirk of WMI is the Win32_volume class. I wanted to check the free disk space and found a sample using the Win32_volume class, but later found the class is not available on XP.
I needed a tool to let me see three things:
- What classes are available
- What properties are in each class
- What methods are available
I normally use WMI Studio (WMI tools) for writing any vbscripts that use WMI but I wanted to browse classes and write WQL in real-time. I also wanted the tool to be portable. So, I had a rummage around my digital toolbox and found not one but two great tools: Microsoft’s free WMI Code Creator and KS-Soft’s free WMI Explorer are two great complements to easier scripting. I will discuss both tools in my next posts in this series.
Want to write for 4sysops? We are looking for new authors.
I do this on a regular basis and have supported up to 25 models. MDT integration makes this a trivial task on XP or 7 using any of the built in variables like Product (which i use). Model is a little trickier (especially with HP). MDT integration also makes WMI easier to use.