Hi I have used the following code to export mailbox details to a csv.
Get-Mailbox -ResultSize Unlimited -SortBy Displayname |
ForEach-Object {
$mbx = $_ | Select DisplayName, Alias, RecipientTypeDetails
$Inboxstats = Get-MailboxFolderStatistics $_ -FolderScope Inbox | Where {$_.foldertype -eq "Inbox"} | Select ItemsInFolder, FolderSize
$Calstats = Get-MailboxFolderStatistics $_ -FolderScope Calendar | Where {$_.foldertype -eq "Calendar"} | Select ItemsInFolder, FolderSize
Get-MailboxStatistics $_ | ForEach {
$mbx | Add-Member -MemberType NoteProperty -Name "Mailbox Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Mailbox Total Item Count" -Value $_.ItemCount
$mbx | Add-Member -MemberType NoteProperty -Name "Inbox Total Size (MB)" -Value $InboxStats.FolderSize.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Inbox Total Item Count" -Value $Inboxstats.ItemsInFolder
$mbx | Add-Member -MemberType NoteProperty -Name "Calendar Total Size (MB)" -value $Calstats.FolderSize.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Calendar Total Item Count" -value $Calstats.ItemsInFolder
}
$mbx
} | export-csv -notypeinformation c:\test3.txt
___________________________________
However i need to also unclude "Sent Items", "Deleted Items" and a custom folder called "Iris Mail Law"
I changed the code to the following:
Get-Mailbox -ResultSize Unlimited -SortBy Displayname |
ForEach-Object {
$mbx = $_ | Select DisplayName, Alias, RecipientTypeDetails
$Inboxstats = Get-MailboxFolderStatistics $_ -FolderScope Inbox | Where {$_.foldertype -eq "Inbox"} | Select ItemsInFolder, FolderSize
$Calstats = Get-MailboxFolderStatistics $_ -FolderScope Calendar | Where {$_.foldertype -eq "Calendar"} | Select ItemsInFolder, FolderSize
Get-MailboxStatistics $_ | ForEach {
$mbx | Add-Member -MemberType NoteProperty -Name "Mailbox Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Mailbox Total Item Count" -Value $_.ItemCount
$mbx | Add-Member -MemberType NoteProperty -Name "Inbox Total Size (MB)" -Value $InboxStats.FolderSize.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Inbox Total Item Count" -Value $Inboxstats.ItemsInFolder
$mbx | Add-Member -MemberType NoteProperty -Name "IRIS LAW MAIL Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "IRIS LAW MAIL Total Item Count" -Value $_.ItemCount
$mbx | Add-Member -MemberType NoteProperty -Name "Sent Items Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Sent Items Total Item Count" -Value $_.ItemCount
$mbx | Add-Member -MemberType NoteProperty -Name "Deleted Items Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Deleted Items Total Item Count" -Value $_.ItemCount
$mbx | Add-Member -MemberType NoteProperty -Name "Calendar Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()
$mbx | Add-Member -MemberType NoteProperty -Name "Calendar Total Item Count" -Value $_.ItemCount
}
$mbx
} | export-csv -notypeinformation c:\mailboxdetails.txt
However in the csv files the Iris Law, sent items and deleted items pull the exact same data as Calender stats, tinkered with it abit more and i keep gettin errors, been on this since 10am now any help would be so grateful.
Thanks in advance