4 Replies Latest reply on Jun 19, 2014 5:19 PM by Ben 10

    Edit smartgroup rule

      Hi everyone,

       

      I'm trying to modify a rule in a smartgroup with blcli command.

       

      Exemple: I have a smartgroup named "Windows Server 2003" with the rule "Any Server Where OS_Version equals 2003".

       

      There's a way to modify the smargroup rule?

       

      I would like to know where I can find the blcli command to do this or if you have an exemple?

       

      Thanks!

        • 1. Re: Edit smartgroup rule
          Bill Robinson

          It’s probably easier to clear the conditions and then re-create them.

          • 2. Re: Edit smartgroup rule

            1- There's no blcli command to modify the condition in a smartgroup?

             

            2- Where I can found the blcli command to clear the condition and re-create?

             

            Thanks Bill!

            • 3. Re: Re: Edit smartgroup rule
              Yanick Girouard

              If this can help, here's a sample of a script I wrote to update a server smartgroup. You can probably adapt it for what you want to do, but the essential that you need is there:

               

              # This is an example
              # You must first create your server smartgroup and this will overwrite the conditions with a single "is one of" list of servers
              
              SERVER_LIST="server1 server2 server3"
              
              for s in $SERVER_LIST; do
                  SERVER_ARRAY+=($s)
              done
              
              IFS_BACKUP=$IFS
              IFS=","
              SERVERS="${SERVER_ARRAY[*]}"
              IFS=$IFS_BACKUP
              
              echo "List of servers: ${SERVERS}"
              
              blcli_execute Group getGroupByQualifiedName 5007 "/Path/To/SmartGroup"
              echo
              blcli_execute Utility storeTargetObject sgObject
              echo
              blcli_execute Condition createPropertyCondition "Class://SystemObject/Server" "NAME" "is one of" "[${SERVERS}]"
              echo
              blcli_execute Utility storeTargetObject conditionObject
              echo
              blcli_execute SmartGroup resetConditions NAMED_OBJECT=sgObject NAMED_OBJECT=conditionObject
              echo
              blcli_execute SmartGroup save NAMED_OBJECT=sgObject
              echo
              
              • 4. Re: Edit smartgroup rule

                Thanks Yannick!

                 

                I will try this!