locked
Powershell - how to - get mailbox samaccount and mailbox stats RRS feed

  • Question

  • Hi,

    I was wondering if someone could help me some Exchange powershell.

    I'm trying to get, from all users, their SamAccountName and their TotalItemSize (from the Get-MailboxStatistics command) output to table format.

    SamAccountName TotalItemSize

    I can obiviously get them by running two seperate commands however I can't seem to combine them so they output to a table.

    Any help would be appreciated

    Monday, August 1, 2011 10:46 PM

Answers

  • On Mon, 1 Aug 2011 22:46:29 +0000, 1ill wrote:
     
    >
    >
    >Hi,
    >
    >I was wondering if someone could help me some Exchange powershell.
    >
    >I'm trying to get, from all users, their SamAccountName and their TotalItemSize (from the Get-MailboxStatistics command) output to table format.
    >
    >SamAccountName TotalItemSize
    >
    >I can obiviously get them by running two seperate commands however I can't seem to combine them so they output to a table.
    >
    >Any help would be appreciated
     
    Try this (modify as needed):
     
    $r=@();get-mailbox | foreach {$l = ""|Select Account,Size; $l.account
    = $_.samaccountname; $l.Size = (get-mailboxstatistics -id
    $_.distinguishedname).totalitemsize; $r += $l}; $r | export-csv
    c:\temp\name.csv -notype -encoding ascii
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Marked as answer by 1ill Tuesday, August 2, 2011 6:15 AM
    Tuesday, August 2, 2011 2:55 AM

All replies

  • On Mon, 1 Aug 2011 22:46:29 +0000, 1ill wrote:
     
    >
    >
    >Hi,
    >
    >I was wondering if someone could help me some Exchange powershell.
    >
    >I'm trying to get, from all users, their SamAccountName and their TotalItemSize (from the Get-MailboxStatistics command) output to table format.
    >
    >SamAccountName TotalItemSize
    >
    >I can obiviously get them by running two seperate commands however I can't seem to combine them so they output to a table.
    >
    >Any help would be appreciated
     
    Try this (modify as needed):
     
    $r=@();get-mailbox | foreach {$l = ""|Select Account,Size; $l.account
    = $_.samaccountname; $l.Size = (get-mailboxstatistics -id
    $_.distinguishedname).totalitemsize; $r += $l}; $r | export-csv
    c:\temp\name.csv -notype -encoding ascii
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Marked as answer by 1ill Tuesday, August 2, 2011 6:15 AM
    Tuesday, August 2, 2011 2:55 AM
  • Hi Rich,

    I've done a quick test and that seems to work! awesome. Thanks a lot.

    Cheers,

    Garry

    Tuesday, August 2, 2011 6:15 AM