header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Total number of mailboxes on a server
Last Post 12 Jul 2010 06:31 AM by Rob. 8 Replies.
Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
RobUser is Offline
New Member
New Member
Posts:32
Avatar

--
09 Jul 2010 07:02 AM
    Hi
    Is there away to output the total number of mailboxes. I can get the total for each mail store but i can't find away to total them up so i can quickly see how many users/mailboxes there are on each server.

    I'm running EX2K3.

    Thanks
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1643
    Avatar

    --
    09 Jul 2010 07:05 AM
    http://get-scripting.blogspot.com/2...art-1.html

    You can use WMI to script against Exchange 2003.
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    RobUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    09 Jul 2010 07:59 AM
    Thanks, I'v already used that before, but i was kinda looking at away to total all of that together i thought of using the Select-Object MailboxCount but that doen't seem to be working.
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1643
    Avatar

    --
    09 Jul 2010 08:07 AM
    If you just need a really simple count, you can simply do this:
    PS> (my_powershell_commands).count
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    RobUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    09 Jul 2010 03:09 PM
    Thanks for that here is what i have come up with.

    $ComputerName = "lon03",
    foreach ($Store in $ComputerName){
    $Total = (Get-WmiObject Exchange_Mailbox -NameSpace Root\MicrosoftExchangeV2 -ComputerName $ComputerName | Select-Object StoreName).count
    Write-Host $Store ":" $Total "users"
    }

    Which out-puts

    lon03 : 2649 users

    This is correct, the only problem i'm now having is that i have another 3 servers, but if i add them to the $ComputerName =, the output is just all the servers added together. I need a way to split them up in to each server.

    e.g.
    lon03 : 2649 users
    lon04 : xxxx users
    lon04 : xxxx users
    lon05 : xxxx users
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1643
    Avatar

    --
    09 Jul 2010 05:20 PM
    OK, there's a problem with your logic.

    Maybe this is what you meant to do:
    $ComputerName = "lon03","lon04","lon05"
    foreach ($Store in $ComputerName){
    $Total = (Get-WmiObject Exchange_Mailbox -NameSpace Root\MicrosoftExchangeV2 -ComputerName $ComputerName | Where {$_.StoreName} -eq $store).count
    Write-Host $Store ":" $Total "users"
    }

    If that performs slowly, there's optimizations that can be done:
    $ComputerName = "lon03","lon04","lon05"
    $mailboxes=Get-WmiObject Exchange_Mailbox -NameSpace Root\MicrosoftExchangeV2 -ComputerName $ComputerName
    foreach ($Store in $ComputerName){
    $Total = ( $mailboxes| Where {$_.StoreName} -eq $store).count
    Write-Host $Store ":" $Total "users"
    }
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    RobUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    11 Jul 2010 09:47 AM
    I'm getting an error with both versions the below is the one from the bottom version.

    A parameter cannot be found that matches parameter name 'eq'.
    At :line:4 char:47
    + $Total = ($mailboxes | Where {$_.StoreName} -eq <<<< $Store).count
    Marco Shaw (MVP)User is Offline
    Veteran Member
    Veteran Member
    Posts:1643
    Avatar

    --
    11 Jul 2010 07:15 PM
    Bah! Sorry!

    This part:
    "Where {$_.StoreName} -eq $store).count"

    Should be:
    Where {$_.StoreName -eq $store}).count
    Marco

    *Microsoft MVP - Windows PowerShell
    https://mvp.support.microsoft.com/profile/Marco.Shaw
    *Co-Author - Sams Windows PowerShell Unleashed 2nd Edition
    *Blog - http://marcoshaw.blogspot.com
    RobUser is Offline
    New Member
    New Member
    Posts:32
    Avatar

    --
    12 Jul 2010 06:31 AM
    Dam should have see that. No errors now but $Total is not showing a value.
    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