Link to home
Create AccountLog in
Avatar of happyexchange

asked on


Hi, in our first storage group on Exchange 2007 we want to create another 5.  Is there a script i can use to Move users, give the storage group a max size and user a max email size.
I want to split the users - so for example withing storage group 1 - No 1 will be users a - e
Storage size and users size.

Hope there is a script for that.

Avatar of Dale Harris
Dale Harris
Flag of United States of America image

What I would do if I were you is create the next 5 manually.

Then, I have a script that I use to move users by name to a different mailstore.
Note: You must install Quest CMDLets for this to work.

I had to run this on my exchange to get this to work:

$letters = "A","B","C","D" #you can add or take away letters
$users = get-qaduser -searchroot "ou=users,dc=contoso,dc=com"
$DestinationDB = "EXCH2"
foreach ($user in $users){
foreach ($letter in $letters){
$Username = "CONTOSO\$($User.samaccountname)"
if ($Username.startswith($letter)){
Write-Host "Moving $Username to $DestinationDB"
move-mailbox -identity $Username -BadItemLimit '0' -TargetDatabase "$DestinationDB\First Storage Group\Mailbox Database"
}#end If Username starts with letter
}#end foreach letter
}#end foreach user

What you could also do is move one user manually, then copy the code from the GUI and just change it around to match your needs.


Dale Harris
Avatar of Chris Dent

Splitting people into stores based on surname? That's fine, we can do that automatically, what do you want to happen when you reach the maximum store size / maximum number of users in a store?

Personally I gave up on distributing people into stores based on their name and just went for throwing them into the smallest store. However, I've used pretty detailed name-based distribution schemes in the past and will happily write you a little script if that's what you want :)

Avatar of Chris Dent
Chris Dent
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of happyexchange


Thanks Chris, they do want people to move into different storage groups and split the users by A - E and so on.
I shall try your script, thanks for all your help

No problem. If in doubt, run this line first:
Get-MailboxDatabase | Select-Object Identity, @{n='Range';e={ $_.Identity -Replace '^.*(?=\w\s-\s\w)' }}

Open in new window

If Range is empty it won't work, that bit has to be right for everything else to work.

Thank you