header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Error Retrieving Total Number of Mailboxes in Exchange
Last Post 24 Jun 2010 04:49 AM by Shay Levy. 7 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages Not Resolved
justin82User is Offline
New Member
New Member
Posts:25
Avatar

--
01 Jun 2010 01:02 AM
    Hi Folks I borrowed this script from your community to extract the number of mailboxes in our environment and it reported errors, pasted below:
    Get-MailboxStatistics : The specified mailbox database "ServerName\MailDatabase 1" is not unique. At line:12 char:38
    Get-ChildItem : Cannot find path '\\ServerName\H$\Store1718\SG17\MailDatabase1. edb' because it does not exist.


    Script as executed:::
    ## PowerShell.exe -PSConsoleFile "C:\Program Files\Microsoft\Exchange Server\Bin\ExShell.psc1" -Command ". 'C:\Program Files\Microsoft Identity Integration Server\MaData\count2.ps1'"
    $MailboxCount = "C:\Program Files\Microsoft Identity Integration Server\MaData\MailboxCount.csv" $exchangeservers = Get-ExchangeServer |where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }
    $AllServers = @()
    foreach ($server in $exchangeservers)
    { $db = Get-MailboxDatabase -server $server foreach ($objItem in $db)
    { $edbfilepath = $objItem.edbfilepath $path = "`\`\" + $server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2)
     $dbsize = Get-ChildItem $path $start = $path.LastIndexOf('\') $dbpath = $path.Substring($start +1).remove($path.Substring($start +1).length -4)
    $mailboxpath = "$server\$dbpath"
     $mailboxcount = Get-MailboxStatistics -database "$mailboxpath" |measure-object
    $ReturnedObj = New-Object PSObject
    $ReturnedObj | Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
    #$ReturnedObj | Add-Member NoteProperty -Name "Size (MB)" -Value ("{0:n2}" -f ($dbsize.Length/1024KB))
    $ReturnedObj | Add-Member NoteProperty -Name "Mailbox Count" -Value $mailboxcount.count $AllServers += $ReturnedObj } }

    $AllServers |export-csv c:\testcount.csv -notype -force

    We have 6 clustered servers across which our mailbox database is stored.
    Vishal RamnaniUser is Offline
    New Member
    New Member
    Posts:68
    Avatar

    --
    07 Jun 2010 01:40 AM
    This script does much more than calculating the number of mailboxes in the env.

    Instead you just try running below command to get number of mailboxes in your env. or let us know what is your exact requirement.

    (Get-mailbox -resultsize Unlimited).count

    Thanks.
    Vishal Ramnani
    MCITP - Exchange 2007, MCSE Messaging, MCTS - Win 2008 Config
    justin82User is Offline
    New Member
    New Member
    Posts:25
    Avatar

    --
    07 Jun 2010 06:46 PM

    Hi Vishal

    I have been assigned the task to write a script which reports the number of mailboxes in our environment. The script should poll the exchange database and send an email to a monitoring mailbox on the total number of mailboxes.

    Another requirement is when the mailboxes have exceeded 96000 it should stop the creation of mailboxes in our exchange environment.

    I have been trying to find all the resources on internet to accomplish, any help on this would be greatly appreciated.

    Best Regards
    Justin

    PresenceUser is Offline
    New Member
    New Member
    Posts:94
    Avatar

    --
    07 Jun 2010 07:27 PM
    $count = (get-mailbox -resultsize unlimited).count

    .....

    $mail.subject = "There are $count number of mailboxes in the environment"
    http://www.powershellpro.com/powers...lerts/210/ ##link describes sending an email through PS.

    .....

    set up a rule in the monitoring mailbox that say once the it see's a message with 96000 in the subject... forward it to you...

    then, once you see that message, go and strip the permissions that allow people to create new mailboxes...
    probably a PS solution to do it all, but this just seems the simplest...

    Thanks
    Pres.
    justin82User is Offline
    New Member
    New Member
    Posts:25
    Avatar

    --
    14 Jun 2010 01:47 AM
    • Accepted Answer
    Hi Folks

    script pasted below did the job for me!! thanx for ur time!

    ####################################################################


    $exchangeservers = Get-ExchangeServer |where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }
    $AllServers = @()
    foreach ($server in $exchangeservers)
    {
    $db = Get-MailboxDatabase -server $server
    foreach ($objItem in $db)
    {

    $mailboxcount = Get-MailboxStatistics -database $objItem |measure-object
    $ReturnedObj = New-Object PSObject
    $ReturnedObj | Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
    $ReturnedObj | Add-Member NoteProperty -Name "Mailbox Count" -Value $mailboxcount.count
    $AllServers += $ReturnedObj
    }
    }

    $AllServers |export-csv c:\MailboxCount.csv -notype -force
    justin82User is Offline
    New Member
    New Member
    Posts:25
    Avatar

    --
    24 Jun 2010 04:35 AM

    Hi folks

    For some wierd reasons, the script pasted above, failed to give an output:

    "Server\StorageGroup\Database","Mailbox Count"
    ,

    It only outputs a comma and nothing else. I am zapped out, Please assist

    I am pasting the script for your reference, any pointers on where i went wrong?
    ######################################
    $exchangeservers = Get-ExchangeServer |where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }
    $AllServers = @()
    foreach ($server in $exchangeservers)
    { $db = Get-MailboxDatabase -server $server
    foreach ($objItem in $db)
    { $mailboxcount = Get-MailboxStatistics -database $objItem |measure-object 
    $ReturnedObj = New-Object PSObject
    $ReturnedObj | Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
    $ReturnedObj | Add-Member NoteProperty -Name "Mailbox Count" -Value $mailboxcount.count $AllServers += $ReturnedObj } }

    $AllServers |export-csv c:\test4.csv -notype -force

    justin82User is Offline
    New Member
    New Member
    Posts:25
    Avatar

    --
    24 Jun 2010 04:38 AM
    please note the script is the same as posted in my write up on 14 Jun 2010 10:47 AM
    Shay LevyUser is Offline
    PowerShell MVP, Admin
    Veteran Member
    Veteran Member
    Posts:1362
    Avatar

    --
    24 Jun 2010 04:49 AM
    How about

    Get-MailboxServer | Get-MailboxDatabase | Get-MailboxStatistics | Group-Object Database -NoElement

    Shay Levy
    Windows PowerShell MVP
    http://PowerShay.com
    PowerShell Community Toolbar
    Twitter: @ShayLevy
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer