Jump to content

Recommended Posts

Posted

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 :)

Posted

Amended the code just to add on sent items:

 

 

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

$SentItemstats = Get-MailboxFolderStatistics $_ -FolderScope SentItems | Where {$_.foldertype -eq "SentItems"} | 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 $_.TotalItemSize.Value.ToMB()

$mbx | Add-Member -MemberType NoteProperty -Name "Calendar MAIL Total Item Count" -Value $_.ItemCount

$mbx | Add-Member -MemberType NoteProperty -Name "SentItems Total Size (MB)" -Value $_.TotalItemSize.Value.ToMB()

$mbx | Add-Member -MemberType NoteProperty -Name "SentItems Total Item Count" -Value $_.ItemCount

 

}

$mbx

 

} | export-csv -notypeinformation c:\mailboxdetails.txt

 

 

It exported to the csv file however the data in the sent items column is the same as the calendars columns for all users, so the sent items must of pulled the calendars data instead :S really confused.

Posted (edited)

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

$SentItemsstats = Get-MailboxFolderStatistics $_ -FolderScope SentItems | Where {$_.foldertype -eq "SentItems"} | Select ItemsInFolder, FolderSize

$DeletedItemsstats = Get-MailboxFolderStatistics $_ -FolderScope DeletedItems | Where {$_.foldertype -eq "DeletedItems"} | 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 | Add-Member -MemberType NoteProperty -Name "SentItems Total Size (MB)" -value $SentItemsstats.FolderSize.ToMB()

$mbx | Add-Member -MemberType NoteProperty -Name "SentItems Total Item Count" -value $SentItemsstats.ItemsInFolder

$mbx | Add-Member -MemberType NoteProperty -Name "DeletedItems Total Size (MB)" -value $DeletedItemsstats.FolderSize.ToMB()

$mbx | Add-Member -MemberType NoteProperty -Name "DeletedItems Total Item Count" -value $DeletedItemsstats.ItemsInFolder

 

}

$mbx

 

 

} | export-csv -notypeinformation c:\FullReport2.txt

 

 

Above is the the method i final used to export the data, however any one know how i would add another Line on for a custom names folder thats in every ones mailbox

Edited by jammywv

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...