Determine lowest used database
Hello everyone, We have several mailboxdatabaes on our exchange server. When I create new users, I want them to be created on the database, with the lowest usage. I have actually a powershell script, which looks like this: $db1 foreach $db2 foreach $db3 foreach if if if I works quite well, but we are about to get a lot of more mailboxes, so this script will get very complicated. Is there some kind of funtion in PS, which automatically selects from the variables the smallest? Or any other smart solution :) ? Thanks in advance! ( ($db1t -lt $db2t) -and ($db1t -lt $db3t) { $dbcreate="***\Storage Group 01\Mailbox Database 01" }( ($db2t -lt $db1t) -and ($db2t -lt $db2t) { $dbcreate="***\Storage Group 02\Mailbox Database 02" }( ($db3t -lt $db1t) -and ($db3t -lt $db2t) { $dbcreate="***\Storage Group 03\Mailbox Database 03" }( $db3s in $db3 ) { $db3t = $db3t + $db3s.TotalDeletedItemSize + $db3s.TotalItemSize }= Get-MailboxStatistics -database "***\Storage Group 03\Mailbox Database 03"( $db2s in $db2 ) { $db2t = $db2t + $db2s.TotalDeletedItemSize + $db2s.TotalItemSize }= Get-MailboxStatistics -database "***\Storage Group 02\Mailbox Database 02"( $db1s in $db1 ) { $db1t = $db1t + $db1s.TotalDeletedItemSize + $db1s.TotalItemSize }= Get-MailboxStatistics -database "***\Storage Group 01\Mailbox Database 01"
September 24th, 2010 9:04am

Yikes! I can't read that. First, I wouldn't count the deleted item size when doing this kind of calculation because that stuff is going away in short order anyway. Here's a script I just wrote for this purpose. It shows the ten databases with the least total mailbox sizes in sorted order from smallest to largest. $DBs = @() $MB = Get-MailboxDatabase $MB | ForEach-Object { $Total = 0 $_.Name Get-MailboxStatistics -Database $_.Name | ForEach-Object {$Total += $_.TotalItemSize.Value.ToBytes()} $DB = New-Object System.Object $DB | Add-Member -Type NoteProperty -Name Name -Value $_.Name $DB | Add-Member -Type NoteProperty -Name TotalItemSize -Value $Total $DBs += $DB } $DBs | Sort-Object TotalItemSize | Select-Object -First 10Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
September 25th, 2010 4:50pm

On Sat, 25 Sep 2010 20:48:41 +0000, Ed Crowley [MVP] wrote: > > >Yikes! I can't read that. > >First, I wouldn't count the deleted item size when doing this kind of calculation because that stuff is going away in short order anyway. > >Here's a script I just wrote for this purpose. It shows the ten databases with the least total mailbox sizes in sorted order from smallest to largest. > >$DBs = @() $MB = Get-MailboxDatabase $MB | ForEach-Object { $Total = 0 $_.Name Get-MailboxStatistics -Database $_.Name | ForEach-Object {$Total += $_.TotalItemSize.Value.ToBytes()} $DB = New-Object System.Object $DB | Add-Member -Type NoteProperty -Name Name -Value $_.Name $DB | Add-Member -Type NoteProperty -Name TotalItemSize -Value $Total $DBs += $DB } > >$DBs | Sort-Object TotalItemSize | Select-Object -First 10 I just randomize the choice database from the set of all available databases. If you do that for each new mailbox you're pretty well assured you'll have databases that are approximately the same size and carry the same number of mailboxes. --- Rich Matheisen MCSE+I, Exchange MVP --- Rich Matheisen MCSE+I, Exchange MVP
September 25th, 2010 5:48pm

I agree with that in principle unless some unusual events have caused a substantial imbalance or you've added some databases or servers.Ed Crowley MVP "There are seldom good technological solutions to behavioral problems."
Free Windows Admin Tool Kit Click here and download it now
September 27th, 2010 12:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics