This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Script Search - divide 1000 computers into 9 groups based on attribute value

I have what should be a very simple task on my plate that I can't seem to hit with a fork.

I have 9 groups and 2000 servers.  I need to split the servers between the groups ...

and as a maintenance workflow, when a new server comes online, after update of the OS value, move it into the least populated of the 9 groups.

I have a script started, that populates a native attribute on server objects with their AD site.  I divide the collected site names into two collections.  Each collection contains a couple thousand servers mapped to those sites.  I have 9  AD groups for each site collection..  I can split 2000 by 9, but here's the black hole in my logic, Nested Loops..

Do you have any scriptlets or script samples that demonstrate how to loop foreach group, add 1/9th of the 2000 servers into said group, then for the next group, grab the next 1/9th of the servers, etc ...  until done, amen.

fun times.

thanks in advance 

Parents
  • It appears that you have 6 sites. Yet you have 9 groups. Why not have 6 groups? Or 12 groups?

    The site affinity *seems* like a logical way to carve up the servers?

    So why not have your groups setup thus:

    ADSITE1_1 Servers
    ADSITE1_2 Servers
    ADSITE2_1 Servers
    ADSITE2_2 Servers
    ADSITE3_1 Servers
    ADSITE3_2 Servers

    ...and so on?

    Maybe there's some reason not to do it this way?

    (I clearly struggle with the notion of randomly distributing the servers among various groups)
Reply
  • It appears that you have 6 sites. Yet you have 9 groups. Why not have 6 groups? Or 12 groups?

    The site affinity *seems* like a logical way to carve up the servers?

    So why not have your groups setup thus:

    ADSITE1_1 Servers
    ADSITE1_2 Servers
    ADSITE2_1 Servers
    ADSITE2_2 Servers
    ADSITE3_1 Servers
    ADSITE3_2 Servers

    ...and so on?

    Maybe there's some reason not to do it this way?

    (I clearly struggle with the notion of randomly distributing the servers among various groups)
Children
No Data