Dell BIOS Versions - Optimize Relevance

(imported topic written by SystemAdmin)

I wrote a task to check for specific model Dell machines, if they had less than the latest version of their BIOS, and then deploy the updates to them. It’s working but I can’t imagine that I did a very good job of optimizing the relevance. Can anybody take a crack at making this better?

Relevance:

(name of operating system as lowercase starts with “win”) AND (exists wmi) AND ( (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “latitude e5500”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < ")) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “latitude e6500”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A16”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “latitude d630c”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A10”)) OR ((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “latitude d830”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A14”) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “optiplex 740”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “2.2.3”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “optiplex 745”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “2.6.2”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “optiplex 960”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A05”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “precision workStation 650”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A05”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “precision workStation 650”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A05”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “precision workStation 670”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A07”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “precision workStation 530 mt”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A11”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “optiplex gx260”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A09”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “optiplex gx620”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A10”)) OR (((string value of selects “Model from Win32_ComputerSystem” of wmi) as trimmed string as lowercase = “dimension 4600i”) AND ((substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string)) < “A12”)) )

Action:

//Dell Latitude E5500 update to BIOS version A13 IF 
{ (((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"latitude e5500") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A13"))   
} waithidden __Download\E5500A13.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Latitude 65500 update to BIOS version A16 IF 
{ (((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"latitude e6500") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A16"))  
} waithidden __Download\E6500A16.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Latitude D630C update to BIOS version A10 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"latitude d630c") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A10"))
} waithidden __Download\D630CA10.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Latitude D830 update to BIOS version A14 IF 
{((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"latitude d830") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A14")
} waithidden __Download\D830_A14.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell OptiPlex 740 update to BIOS version 2.2.3 
//IF {(((string value of selects "Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = "optiplex 740") AND ((substring after "=" of (selects ("SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < "2.2.3"))} 
//waithidden __Download\O740-223.EXE -NOPAUSE -NOREBOOT 
//ENDIF   
//Dell OptiPlex 745 update to BIOS version 2.6.2 
//IF {(((string value of selects "Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = "optiplex 745") AND ((substring after "=" of (selects ("SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < "2.6.2"))} 
//waithidden __Download\o745-020602.exe -NOPAUSE -NOREBOOT 
//ENDIF   
//Dell OptiPlex 960 update to BIOS version A05 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"optiplex 960") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A05"))
} waithidden __Download\O960-A05.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Precision Workstation 650 update to BIOS version A05 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"precision workstation 650") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A05"))
} waithidden __Download\WS650A05.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Precision Workstation 670 update to BIOS version A07 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"precision workstation 670") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A07"))
} waithidden __Download\WS670A07.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Precision Workstation 530 MT update to BIOS version A11 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"precision workstation 530 mt") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A11"))
} waithidden __Download\WS530A11.exe -NOPAUSE -NOREBOOT ENDIF   
//Dell OptiPlex GX260 update to BIOS version A09 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"optiplex gx260") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A09"))
} waithidden __Download\GX260A09.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell OptiPlex GX620 update to BIOS version A10 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"optiplex gx620") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A10"))
} waithidden __Download\GX620A10.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Dimension 4600i update to BIOS version A12 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"dimension 4600i") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A12"))
} waithidden __Download\D4600A12.EXE -NOPAUSE -NOREBOOT ENDIF   
//Dell Inspiron 600m update to BIOS version A17 IF 
{(((string value of selects 
"Model from Win32_ComputerSystem" of wmi) as trimmed string as lowercase = 
"inspiron 600m") AND ((substring after 
"=" of (selects (
"SMBIOSBIOSVersion FROM Win32_BIOS") of WMI as string)) < 
"A17"))
} waithidden __Download\I600mA17.exe -NOPAUSE -NOREBOOT ENDIF

(imported comment written by NoahSalzman)

You are running a bunch of wmi queries unnecessarily. Here is the outline of a better way:

  1. grab “Model from Win32_ComputerSystem” as string… do this once!

  2. have a series of chained if statements (relevance does not support “case” or “switch”) that check to see which machine it is

  3. does one of the if statements match? If yes, you will check the BIOS version inside that if statement… if none of the if statements match then the entire relevance will return false.

Make sense?

(imported comment written by SystemAdmin)

You can try out something like this so you only hit WMI twice. Your code runs about 430ms. This one improves it to 108ms.

Two other issues I noticed:

  1. You have two PC names that are duplicated.

  2. The PC names with “workstation” in the name are spelled “workStation”, though we’re only looking at lowercase values.

Try this:

(exists wmi) and ((preceding text of first “,” of it = “latitude e5500” and following text of first “,” of it < ") or (preceding text of first “,” of it = “latitude e6500” and following text of first “,” of it < “A16”) or (preceding text of first “,” of it = “latitude d630c” and following text of first “,” of it < “A10”) or (preceding text of first “,” of it = “latitude d830” and following text of first “,” of it < “A14”) or (preceding text of first “,” of it = “optiplex 740” and following text of first “,” of it < “2.2.3”) or (preceding text of first “,” of it = “optiplex 745” and following text of first “,” of it < “2.6.2”) or (preceding text of first “,” of it = “optiplex 960” and following text of first “,” of it < “A05”) or (preceding text of first “,” of it = “precision workstation 650” and following text of first “,” of it < “A05”) or (preceding text of first “,” of it = “precision workstation 670” and following text of first “,” of it < “A07”) or (preceding text of first “,” of it = “precision workstation 530 mt” and following text of first “,” of it < “A11”) or (preceding text of first “,” of it = “optiplex gx260” and following text of first “,” of it < “A09”) or (preceding text of first “,” of it = “optiplex gx620” and following text of first “,” of it < “A10”) or (preceding text of first “,” of it = “dimension 4600i” and following text of first “,” of it < “A12”)) of concatenation “,” of ((string value of select “Model from Win32_ComputerSystem” of wmi as trimmed string as lowercase) ; (substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string) as uppercase))

(imported comment written by SystemAdmin)

Interresting. After talking about another topic (http://forum.bigfix.com/viewtopic.php?id=4204), I also tried the following which is even easier to read, but does take a few ms longer to evaluate.

(exists wmi) and ((item 0 of it = “latitude e5500” and item 1 of it < ") or (item 0 of it = “latitude e6500” and item 1 of it < “A16”) or (item 0 of it = “latitude d630c” and item 1 of it < “A10”) or (item 0 of it = “latitude d830” and item 1 of it < “A14”) or (item 0 of it = “optiplex 740” and item 1 of it < “2.2.3”) or (item 0 of it = “optiplex 745” and item 1 of it < “2.6.2”) or (item 0 of it = “optiplex 960” and item 1 of it < “A05”) or (item 0 of it = “precision workstation 650” and item 1 of it < “A05”) or (item 0 of it = “precision workstation 670” and item 1 of it < “A07”) or (item 0 of it = “precision workstation 530 mt” and item 1 of it < “A11”) or (item 0 of it = “optiplex gx260” and item 1 of it < “A09”) or (item 0 of it = “optiplex gx620” and item 1 of it < “A10”) or (item 0 of it = “dimension 4600i” and item 1 of it < “A12”)) of ((string value of select “Model from Win32_ComputerSystem” of wmi as trimmed string as lowercase) , (substring after “=” of (selects (“SMBIOSBIOSVersion FROM Win32_BIOS”) of WMI as string) as uppercase))

(imported comment written by jmorano91)

How would I modify this to be just a specific list of machines, without the BIOS substring?

if (exists wmi) then (string values of selects “Model from Win32_ComputerSystem” of wmi) else (“N/A”) gives the specific model, but I want to check against a list of approved models.

(imported comment written by SystemAdmin)

That gets even easier.

(exists wmi) and (it = “latitude e5500” or it = “latitude e6500” or it = “latitude d630c” or it = “latitude d830” or it = “optiplex 740” or it = “optiplex 745” or it = “optiplex 960” or it = “precision workstation 650” or it = “precision workstation 670” or it = “precision workstation 530 mt” or it = “optiplex gx260” or it = “optiplex gx620” or it = “dimension 4600i”) of (string value of select “Model from Win32_ComputerSystem” of wmi as trimmed string as lowercase)

(imported comment written by NoahSalzman)

Perhaps…

(exists wmi) and ((it = “latitude e5500” ) or (it = “latitude e6500”) or (it = “latitude d630c”) of (string value of select “Model from Win32_ComputerSystem” of wmi as trimmed string as lowercase))

http://doh… answer collision… better than a non-answer non-collision I guess

(imported comment written by jmorano91)

Paul: That works, and thanks.

noah: Yes that failed, sorry.

I am a complete nooblet and thanks for the quick responses, I will keep my eyes glued to this post for any other solutions. Thanks All!

(imported comment written by NoahSalzman)

Yeah, Paul got it right… I shouldn’t have left the parentheses around the (it = machine name) bits.

(imported comment written by SystemAdmin)

Funny, I was just typing something similar. The individual parenthesis is ok, as long as you enclose all of them together with 1 more set.

Here it is with the parentheses…

(exists wmi) and (((it = “latitude e5500”) or (it = “latitude e6500”) or (it = “latitude d630c”)) of (string value of select “Model from Win32_ComputerSystem” of wmi as trimmed string as lowercase))

(imported comment written by BenKus)

FYI… be careful with the trimmed string inspector in BigFix 7.x:

http://forum.bigfix.com/viewtopic.php?pid=17565#p17565

Ben

(imported comment written by brady_admin91)

If you want to avoid WMI all together I am successfully using this for relevance to detect BIOS version:

Sample:

name of operating system starts with “Win” AND (exists key “HKLM\HARDWARE\DESCRIPTION\System” whose (value “SystemBiosVersion” of it as string < ") of native registry)

We tattoo the registry with the model of the PC during our build process so I am using that in my relevance in conjunction with the above relevance.

(imported comment written by SystemAdmin)

How does one filter out the %00 placeholders?

(imported comment written by brady_admin91)

This is what is produced when asking for value “SystemBiosVersion” of key “HKLM\HARDWARE\DESCRIPTION\System” of native registry. I found it to be dynamic on different hardware platforms so just QnA it on each one.