Video Screencast Help
Give us your opinion and win with Symantec! Please help us by taking this survey to tell us about your experience with Symantec Connect, so that we can continue to grow and improve.  Take the survey.

Running Job tasks depending on hardware

Created: 25 Jul 2013 • Updated: 26 Jul 2013 | 10 comments
This issue has been solved. See solution.

I know how to do this in Microsoft Deployment Toolkit but not in CMS. If I have a client job with several tasks in it and I want a specific task to only run on specific hardware based on model number how would I do this.  I know in WDS I would use a Task Sequence and add a WMI query under options to this task

e.g. : Select * FROM Win32_ComputerSystem WHERE Model Like "HP EliteBook 8"

Anyone help ?

Operating Systems:

Comments 10 CommentsJump to latest comment

HighTower's picture

I use this for installing a wireless profile but I'm sure you could modify it to do anything:

FOR /F "tokens=2 delims==" %%G IN ('WMIC baseboard get product /format:VALUE') DO SET Model=%%G

ECHO Model: %Model%

if "%model%"=="30DD"  goto HP6730b
if "%model%"=="1631"  goto HP8560w
if "%model%"=="17A7"  goto hp8570p
if "%model%"=="18DF"  goto HP9470m
if "%model%"=="146D"  goto HP6550p
if "%model%"=="1619"  goto HP6560p
if "%model%"=="18F8"  goto HP810
if "%model%"=="FJNB219" goto FJT730
if "%model%"=="FJNB232" goto FJT731
if "%model%"=="FJNB228" goto FJT901
if "%model%"=="FJNB249" goto FJT902
if "%model%"=="FJNB204" goto FJT900
if "%model%"=="FJNB24B" goto FJQ702
REM if "%model%"=="440BX Desktop Reference Platform" goto VMW

REM If we didn't find a match, just exit
goto Exit

REM LAPTOPS

:HP6730b
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:HP8560w
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:HP8570p
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:HP9470m
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:HP6550p
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:HP6560p
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:HP810
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

REM TABLETS

:FJT730
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:FJT731
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:FJT901
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:FJT902
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:FJT900
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:FJQ702
netsh delete profile name="SSID"
netsh wlan add profile filename="\\SERVER\software\Wireless\Windows\Windows7\WLAN\Bravo\Bravo.xml"
goto Exit

:Exit

exit

BugTastic's picture

Hi Hightower, Thanks for that. That looks like it would work. I was hoping it would be achievable using conditions in a job though. That would be more manageable I think.

BugTastic's picture

Something along these lines where if the model number = 2468 then it rusn the task. I just dont know how to get it to return the model number. below  is the 'Model WMI query' script.

Capture9.PNG

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputerSystem = objWMIService.ExecQuery ("Select * from Win32_computersystem")
Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS")
For each objComputerSystem in colComputerSystem
GetComputerManufacturer = objComputerSystem.Manufacturer
GetComputerModel = objComputerSystem.Model
Next
 

HighTower's picture

If you're thinking of "conditions" with the DS 6.9 mindset they don't work like what you'd expect them to, or want them to.  I think that this gets better in CMS 7.5 but it remains to be seen.

Our 6.9 environment uses LOTS of conditions and I found that using scripts like what I posted has gone a long way to simplifying what we do.  I might have multiple scripts that parse hardware now but if I have to make a change to every "condition" it's easier to do in a text editor now instead of opening up 50+ conditions and modify each one individually.

md investigate's picture

Hi,

we use conditions in many cases.

For staying at the model we use the conditions to find a specific model and exit the script with a defined exit code. This exit code is used to trigger the condition.

REM ****************************
REM Find Model HP Workstations
REM ****************************

FOR /F "tokens=*" %%i IN ('WMIC Computersystem get model^ /value ^| FIND "6000"') DO (Exit 3)
FOR /F "tokens=*" %%i IN ('WMIC Computersystem get model^ /value ^| FIND "8000"') DO (Exit 4)
FOR /F "tokens=*" %%i IN ('WMIC Computersystem get model^ /value ^| FIND "6200"') DO (Exit 5)
FOR /F "tokens=*" %%i IN ('WMIC Computersystem get model^ /value ^| FIND "Z400"') DO (Exit 6)
FOR /F "tokens=*" %%i IN ('WMIC Computersystem get model^ /value ^| FIND "Z820"') DO (Exit 7)

This is a little script we use for driver installation. How you can see, if exit 3 is given back we install package for the model 6000.

The exit code can be defined by yourself.

For your vb-query following code should give you the exit code (in this example only build for model 6200):

strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colComputerSystem = objWMIService.ExecQuery ("Select * from Win32_computersystem")
Set colBIOS = objWMIService.ExecQuery ("Select * from Win32_BIOS")
For each objComputerSystem in colComputerSystem
GetComputerManufacturer = objComputerSystem.Manufacturer
GetComputerModel = objComputerSystem.Model
If objComputerSystem.Model = "HP Compaq 6200 Pro MT PC" then wscript.quit 6200
next
 

As High Tower mentioned, buildung such structure can be very complex and yes maybe a script doing all the things can be easier.

Regards

SOLUTION
BugTastic's picture

Hi md, This is what I am looking for.  Looks good - thanks.

BugTastic's picture

One thing I notice is that the first script will show as failed even though its successful, I assume its becuase its exiting before the end of the script. Is there any way to make this show as successful ?

Thanks

md investigate's picture

Hi,

the problem with failed / successful is about the exit code given back. The only valid exit code for success is exit code 0. Some kind of tasks / software give back 1 for success but mostly 0 = success and other = error.

In this case we want to have other success codes than 0 because we use in conditons. We live with this "errors" as we know it should error out. I'm sorry but I don't know how to come over this.

Only way is to have a tons of scripts and conditions which exits with 0 when the specified model is found and have a big tree of conditions with many sub-conditions to get back all possibilities. But this would be overwhelming.

Regards

JSpur's picture

Have you tried "Installation Error Code Descriptions"?
I have not added to this list but it might help with determining a success

md investigate's picture

Hi,

@JSpur: This feature is only for better comprehensive reporting data. Refer to http://www.symantec.com/docs/HOWTO62819

Regards