Author Posts

July 24, 2018 at 11:05 pm

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

July 24, 2018 at 11:27 pm

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

July 25, 2018 at 5:12 pm

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] += @($_)
$Count++
}

$GroupLists['1'] 
$GroupLists['2']