balance users per db's

Welcome Forums General PowerShell Q&A balance users per db's

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

1 year, 12 months ago.

  • Author
  • #65080

    Points: 1
    Rank: Member

    I got interesting question
    lets say I have 700 test users/mailboxes
    that I want to load balance across 175 databases
    how would I got about doing that?
    for example I have this part nailed down:
    Import-Csv c:\temp\out.csv | ForEach-Object { New-ADuser -path 'OU=OU1,DC=test,DC=corp' -Name $_.samAccountName -samAccountName $_.samAccountName –userPrincipalName $_.userPrincipalName -GivenName $ -Surname $ -displayName $_.displayName -accountpassword (ConvertTo-SecureString $_.Password -AsPlainText -Force) -Enabled $true}
    [array]$databases=1..175 | % { "DB{0:000}" -f $_ }

    this part is where I'm stuck:
    # Enable mailboxes

    Get-User -OrganizationalUnit 'OU=OU1,DC=test,DC=corp' -Filter 'RecipientType -eq "user"' | ForEach-Object { $email = $_.FirstName +"."+ $_.LastName +""; Enable-Mailbox -Identity $_.SamAccountName -DisplayName $_.DisplayName -Alias $_.SamAccountName -PrimarySmtpAddress $email -Database ??????}

    basically need to loop through $databases more then once(cause I got 175 and 700 users)

  • #65083

    Points: 1
    Rank: Member

    There are several ways to accomplish this, but based on what you already have, you could do something like this.

    Get-User -OrganizationalUnit 'OU=OU1,DC=test,DC=corp' -Filter 'RecipientType -eq "user"' | 
    ForEach-Object {
        $dbName =  "DB{0:000}" -f $dbID
        $email = $_.FirstName +"."+ $_.LastName +""
        Enable-Mailbox -Identity $_.SamAccountName -DisplayName $_.DisplayName -Alias $_.SamAccountName -PrimarySmtpAddress $email -Database $dbName
        if ($dbID -eq 175) {$dbID = 0}
  • #65121

    Points: 1
    Rank: Member

    very helpful

The topic ‘balance users per db's’ is closed to new replies.

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