4 Replies Latest reply on Dec 22, 2016 6:42 AM by LOST

    If and Else conditions

    Apprentice

      I have my Public variable setup as

      Search value:

      Manufacturer

       

      Type:

      Database value

       

      Replacement value:

      "Computer"."System"."Manufacturer"

       

      In my template...

      The "If" condition is setup as

      Variable:

      Manufacturer

      =

      Acer

       

       

      The properties of the "If" condition are

      Search value:

      Manufacturer

       

      Type:

      Database value

       

      Replacement value:

      "Computer"."System"."Manufacturer"

       

       

      Now when the template runs its telling me in the Output box: Variable Manufacturer () = Acer = False

       

      Then goes right to my laptop image

       

      Am I missing something here?

        • 1. Re: If and Else conditions
          amagi Expert

          Variables are checked only at provisioning task start, if the target device is a bare metal your variable "manufacturer" is empty

          • 2. Re: If and Else conditions
            MarXtar ITSMMVPGroup

            First response is correct so you have two options:

             

            1: Do a reboot after installing an agent so that when the task starts up again there is an inventory record to lookup against.

            2: Upgrade to 2016.3 as that has a new option as below:

             

            realtimevariable.png

             

            Either way should do the job for you.

             

            Mark McGinn

            MarXtar Ltd/MarXtar Corporation

            http://landeskone.marxtar.co.uk

            LANDESK One Development Partner

             

            Try MarXtar State Management for LANDESK to Better Understand and Manage your Assets

            • 3. Re: If and Else conditions
              Frank Wils ITSMMVPGroup

              Hi Mark,

               

              Your option 1 doesn't work, unfortunately... The variables are really resolved only at the very beginning of the Provisioning Task. Only alternative when not on 2016.3 is to use the action to launch a new template from a Provisioning task. Launching a new template will re-resolve the variables for that new 'task', but you also have an automatic delay of 5 (?) minutes between calling the action and the new template actually launching.

               

              The real-time lookup in 2016.3 is the much better option.

               

              Frank

              • 4. Re: If and Else conditions
                LOST Rookie

                Hi all,

                 

                I've found that it's also possible to use "If... Else" conditions without using variables, which could be a workaround for those who cannot upgrade to 2016.3 :

                 

                - Write a script (batch, powershell...) which identify the value of the desired attribute (for example, wmi query to determine if the device is a laptop or a desktop). An important thing here is the exit code : if the value is what you expect, return '0' else return '1'.

                 

                - Add your "If" condition in your provisioning template

                 

                - Add "Execute file" for your "if" condition and execute your script. You also have to manage the exit code (Expected return value= '0')

                 

                 

                The result is that if the value found on the device by the script is what you expected, actions below the "if" condition will be executed. If not, actions will be ignored.