3 Replies Latest reply on Jul 23, 2019 3:01 PM by KMSigma

    How to use Powershell groups.ps1 script with foreach command?


      Hi All,


      Our team is in need of creating roughly 600-800 groups. I have used the group.ps1 script to create a 1 group at a time, but it would great if we could get some automagic working

      The objective is to have a group per building per priority . There would be potential to have 4 groups per building. I.E.


      BldA P1     BldA P2     BldA P3     ...

      BldB P1     BldB P2     BldB P3     ...

      BldC P1     BldC P2     BldC P3     ...

      ...                ...               ...               ...


      My issue is I have no clue how to add the 'foreach' command into existing script, or what variables I may need to establish.  I have an idea to create a csv, or txt file with the list of buildings, but past that I am unsure how to make the logic work. Here is what I am working with so far.  Ideally the fields in green would be a variable that is pulled from the txt file.




      $members = @(

          @{ Name = "0284 - Kentucky Clinic P3"; Definition = "filter:/Orion.Nodes[CustomProperties.NetworkLayer!='UPS' AND CustomProperties.Building='0284 - Kentucky Clinic' AND CustomProperties.Priority='3']" }




      $groupId = (Invoke-SwisVerb $swis "Orion.Container" "CreateContainer" @(

          # group name

          "0284 - Kentucky Clinic P3",



          # owner, must be 'Core'




          # refresh frequency




          # Status rollup mode:

          # 0 = Mixed status shows warning

          # 1 = Show worst status

          # 2 = Show best status




          # group description

          "Priority 3 Nodes in 0284 - Kentucky Clinic.",



          # polling enabled/disabled = true/false (in lowercase)




          # group members


             "<ArrayOfMemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>",

             [string]($members |% {










      Suggestions/Solutions on where the foreach logic needs to be placed and formatted?