Link to home
Start Free TrialLog in
Avatar of forsters
forstersFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Powershell script to count number of Mailbox folders in Exchange 2010

Hi Experts

I have a simple script that will tell me the number of folders in a users mailbox here:

(get-mailboxfolderstatistics -id %username%).count

Is there anyway to amend this or does anyone have a script that will list all users on the Exchange server and the number of folders each has.

Many thanks
Forsters
Avatar of dnesse
dnesse
Flag of United States of America image

I use this command to report on mailbox size and statistics for all users:
Get-MailboxStatistics -server SERVERNAME| Sort-Object TotalItemSize –Descending | ft DisplayName,TotalItemSize,ItemCount >C:\mailbox.txt

you should be able to incorporate your script into this?
ASKER CERTIFIED SOLUTION
Avatar of Thomas-Mjelde
Thomas-Mjelde
Flag of Norway image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stefor
We can use something like the script I posted here:
https://www.experts-exchange.com/questions/27479690/Piping-multiple-cmdlets-into-a-single-CSV-file.html?cid=1131&anchorAnswerId=37242149#a37242149

$Mailboxes = Get-Mailbox -ResultSize unlimited
$Output = @()
foreach ($Mailbox in $Mailboxes){
   
  $MailboxStatistics = $Mailbox | Get-MailboxStatistics
  $FolderStatistics = $Mailbox | Get-MailboxFolderStatistics
   
  $objUser = New-Object System.Object
  $objUser | Add-Member -MemberType NoteProperty -Name "Name" -Value $Mailbox.Name
  $objUser | Add-Member -MemberType NoteProperty -Name "SamAccountName" -Value $Mailbox.SamAccountName
  $objUser | Add-Member -MemberType NoteProperty -Name "FolderCount" -Value $FolderStatistics.count
  $objUser | Add-Member -MemberType NoteProperty -Name "ItemCount" -Value $MailboxStatistics.ItemCount
  $objUser | Add-Member -MemberType NoteProperty -Name "TotalItemSize" -Value $MailboxStatistics.TotalItemSize.value.ToMB()
   
  $Output += $objUser
}

$Output | Select-Object Name,SamAccountName,FolderCount,ItemCount,TotalItemSize | Export-CSV "Output.csv"

Open in new window

Avatar of forsters

ASKER

Thanks both

Dnesse I could not  manipulate your script to work although it is a useful script so thanks

Thomas-Mjelde your script worked perfectly.  Many thanks