+ Post New Thread
Results 1 to 3 of 3
Enterprise Software Thread, Exporting Mailbox Details to a CSV! Help in Technical; Hi I have used the following code to export mailbox details to a csv. Get-Mailbox -ResultSize Unlimited -SortBy Displayname | ...
  1. #1
    jammywv's Avatar
    Join Date
    Oct 2012
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Exporting Mailbox Details to a CSV! Help

    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

  2. #2
    jammywv's Avatar
    Join Date
    Oct 2012
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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.

  3. #3
    jammywv's Avatar
    Join Date
    Oct 2012
    Posts
    3
    Thank Post
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0
    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
    Last edited by jammywv; 5th October 2012 at 04:31 PM.

SHARE:
+ Post New Thread

Similar Threads

  1. Exchange 2010, exporting mailboxes to .pst.
    By sch in forum Enterprise Software
    Replies: 14
    Last Post: 4th March 2013, 06:20 PM
  2. Replies: 9
    Last Post: 17th October 2012, 12:48 PM
  3. export mailboxes in exchange 2007 to PST
    By ranj in forum Windows
    Replies: 5
    Last Post: 27th August 2009, 11:51 PM
  4. export outlook calender to vcs
    By russdev in forum Windows
    Replies: 3
    Last Post: 22nd February 2006, 10:18 AM
  5. One PC refuses to run script! Help!!!
    By woody in forum Scripts
    Replies: 6
    Last Post: 5th October 2005, 11:37 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •