Separating values into groups

Welcome Forums General PowerShell Q&A Separating values into groups

This topic contains 2 replies, has 2 voices, and was last updated by

7 months ago.

  • Author
  • #105136

    Points: 219
    Rank: Participant

    I've got a list of servernames, database names and database sizes that I want to sort into two groups based on size, alternating between group 1 and group 2. So, biggest in gp1, 2nd biggest in gp2, 3rd biggest in gp1 and 4th biggest in gp 2...etc.
    How can I do that?

    SqlServerInstance  	DatabaseName 	Size(MB)
    SRV1	DB1	1000
    SRV2	DB2	999
    SRV1	DB3	998
    SRV2	DB1	888
    SRV1	DB7	675
    SRV2	DB9	501
    SRV1	DB15	475
  • #105137

    Points: 749
    Helping Hand
    Rank: Major Contributor

    So you want to distribute a group of items evenly to another group of items? The items are different but the underlying problem is the same:

    distribute computers across several groups for wsus using powershell

    • #105236

      Points: 219
      Rank: Participant

      Olaf, yep, that did it, thank you. I appreciate the help

      $Groups = @("1","2")
      $GroupLists = @{}
      $Count = 0
      $list | % {
      $Name = $Groups[$Count % $Groups.Count]
      $GroupLists[$Name] += @($_)

The topic ‘Separating values into groups’ is closed to new replies.

denizli escort samsun escort muğla escort ataşehir escort kuşadası escort