Quantcast
Channel: Symantec Connect - Endpoint Management
Viewing all articles
Browse latest Browse all 7217

Improving client job conditions allowing custom return codes (Windows OS Bit Check)

$
0
0

REQUIREMENTS

 

Create a deployment job that first detects whether the targeted Windows machine is 32 or 64 bit then initiates the appropriate installer.

 

OBSTACLES

 

Unlike DS 6.9, there are no built in conditions on client jobs in 7.x, instead the return code from a previously run task is evaluated in the conditional statement(s).  This allows you to create a client task with a script that returns a code based on a decision (e.g. is this machine 32 bit or 64 bit).  In the client job, you can base your deployment logic on the return code.   The issue is, I don’t see an easy way to add non-zero success codes on a client job (as was offered in DS 6.9).  What is provided is an option to allow the job to continue regardless of failures.  Ignoring failures is not an option for us.  I want our support team to see these failures and act accordingly.  To better illustrate this, please see example below:

 

Conditional Deployment Job with “Fail job if any task fails” option DISABLED (allowed to fail)

  • Run “Script to determine OS bit” (returns 64 for 64 bit OS)
  • IF “Script to determine OS bit” = 64 (returns 0 for TRUE)
  • RUN “64 bit installer” (returns 3 - file not found)
  • ELSE
  • RUN “32 bit installer” (returns false as it should)

In the above example we were able to determine that the targeted machine was 64-bit, but there was an error during the install and the task returned an error code.  Because the “Fail job if any task fails” option was disabled to allow non-zero return codes, we rely on our front-line staff to check back with all tasks within a job to verify success.   I opt for more reliable automation.

 

SOLUTION

 

The question is, where in the 7.x environment can we add success codes?  Software Catalogue.  Basically, what I did was I added a custom executable (script, MSI, EXE) into the Software Catalogue designed to return a code based on the OS Bit.  I add those custom return codes as Software Release success codes.  I create a client task that calls this Software Release and call on that task in all deployment jobs where a 32/64 bit decision is made.

 

Create executable

*** I’m sure you can simply use a script without compiling into an .EXE as I have, but I’ll just go through my approach.  My executable is basically a VBS script compiled as an .EXE.  I compiled my VBS using PrimalScript.  There may be free VBS Compilers out there.

  1. Create a script to determine whether or not the target Windows machine is 32/64 bit.  I’ll add a simple script under the Reference section (at the end of this document).
  2. Using a script compiler utility, compile the script to an .EXE (optional).  

Software Catalogue

  1. Open the Symantec Management Console (SMP)
  2. Navigate to Manage > Software Catalogue
  3. Click on Import
  4. From the Import Software window under Package Contents, click Add
  5. Navigate to the file you create in the previous section and click the Open button
  6. If the filename is not bold, click Set Installation File
  7. Software Type should be Software Release
  8. Click Next
  9. When prompted agree to edit the Software Release after saving
  10. From the Software Release window, click on the Package tab
  11. Under the Command Lines section, click Add Command
  12. Enable “Command Line requires a package” and select your package from the drop-down list
  13. From the Add or Edit Command Line window
    • Name: give your command a meaningful name (e.g. Get OS Bit)
    • Installation file type: if you’ve chosen to go with a script (e.g. VBS), select other.  In my case, I’ve chosen EXE
    • Command type: custom
    • Set as default command for this command type: Yes
    • Command Line: 
      • If you’ve chosen to go with a script, you’ll have to add a command that would launch the script (e.g. “cscript file.vbs”)
      • in my case the command is simply “file.exe”
    • Success codes: enter all success codes here. In my case it’s “10064” for 64-bit and 10032 for 32-bit
  14. Click OK on each window to save your Software Release

Create Quick Software Delivery Task

  1. From SMP, navigate to Jobs/Tasks
  2. Create a new task by right-clicking on the destination container and click on Select > Task
  3. From the Create New Task window, select Quick Delivery
  4. Give it a meaningful name
  5. From the drop-down text box for Software, select the software release you created in the previous section
  6. Verify the correct Command Line and Package values are set
  7. Click OK

Create Deployment Job

  1. From SMP, navigate to Jobs/Tasks
  2. Create a new job by right-clicking on the destination container and click on Select > Client Job
  3. From the Job section (right), give the job a meaningful name
  4. Click on Add Existing
  5. Navigate to the Quick Software Delivery Task you created in the previous section.  For the sake of this example, we’ll name this task “OS Bit Check”
  6. Click OK
  7. Click New > Condition
  8. Edit condition so it displays something similar to the following:
    • Where: [ OS Bit Check - Return Value ] [ Equals ] [ 10064 ]
  9. Click OK
  10. Click Add Existing and select the 64 bit installer task/job
  11. Click Add Existing and select the 32 bit installer task/job
  12. Your deployment job should looks something like the following:
    Job Start
        Run “OS Bit Check”
        If “OS Bit Check” Return Value equals 10064
            Run “64 bit installer”
        Else
            Run “32 bit installer”
    Stop
  13. Make sure the checkbox for “Fail if any job fails” is checked
  14. Click Save Changes

REFERENCE MATERIAL

 

VBS Script to determine 32/64 bit OS

'************************************************************************************************************************************************

' VARIABLE DEFINITION

'************************************************************************************************************************************************

 

CONST HKEY_LOCAL_MACHINE  = &H80000002

 

'************************************************************************************************************************************************

' FUNCTIONS

'************************************************************************************************************************************************

 

function getBitWidth(strComputerName)

    set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\"& strComputerName & "\root\default:StdRegProv") 

    strKeyPath = "HARDWARE\DESCRIPTION\System\CentralProcessor\0"

    strValueName = "Identifier"

    

    objReg.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strValue

 

    if (instr(strValue,"64")) then

        getBitWidth = 64

    else 

        getBitWidth = 32

    end if

end function

 

function getOSVersion(strComputerName)

    set objWMI = GetObject("winmgmts://"& strComputerName & "/root/cimv2")

    set colItems = objWMI.ExecQuery("Select * from Win32_OperatingSystem",,48)

 

    for each objItem in colItems

        strOSVersion = left(objItem.Version, 3)

    next

 

    getOSVersion = strOSVersion

end function

 

'************************************************************************************************************************************************

' BEGIN

'************************************************************************************************************************************************

 

strComputerName = "."'local

intBitWidth = getBitWidth(strComputerName)

strOSVersion = getOSVersion(strComputerName)

 

select case strOSVersion

    case "6.1" : strOSName = "Windows 7"

    case "6.0" : strOSName = "Windows Vista"

    case "5.2" : strOSName = "Windows 2003"

    case "5.1" : strOSName = "Windows XP"

    case "5.0" : strOSName = "Windows 2000"

    case "4.0" : strOSName = "Windows NT 4.0"

    case else : strOSName = "Windows 9x"

end select

 

WScript.Quit("100"& intBitWidth)

 


Viewing all articles
Browse latest Browse all 7217

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>