Announcement

Collapse
No announcement yet.

Report on all mailbox sizes and last logon piped to CSV

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Report on all mailbox sizes and last logon piped to CSV

    I'm using the following PS script to report on all mailboxes, their sizes and who logged onto them last.
    Code:
    [PS]Get-Exchangeserver | where-object {$_.IsHubTransportServer -eq "True"} | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(KB)";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount,LastLogonTime,LastLoggedOnUserAccount,ObjectClass,ServerName
    How do I pipe this to a CSV file? I tried adding " | export-csv c:\test.csv" to the end but that results in some other data in the file. Thanks.
    Last edited by Rems; 22nd September 2010, 09:42.
    |
    +-- JDMils
    |
    +-- Regional Systems Engineer, DotNet programmer & Jack of all trades
    |

  • #2
    Re: Report on all mailbox sizes and last logon piped to CSV

    please review: http://blogs.msdn.com/b/powershell/a...ng-useful.aspx
    Basically the Format-Table command might give you the issues.

    Export-CSV c:\test.txt should work
    Marcel
    Technical Consultant
    Netherlands
    http://www.phetios.com
    http://blog.nessus.nl

    MCITP(EA, SA), MCSA/E 2003:Security, CCNA, SNAF, DCUCI, CCSA/E/E+ (R60), VCP4/5, NCDA, NCIE - SAN, NCIE - BR, EMCPE
    "No matter how secure, there is always the human factor."

    "Enjoy life today, tomorrow may never come."
    "If you're going through hell, keep going. ~Winston Churchill"

    Comment


    • #3
      Re: Report on all mailbox sizes and last logon piped to CSV

      Marcel,

      Using the reference you provided, I changed the command to:
      Get-Exchangeserver | where-object {$_.IsHubTransportServer -eq "True"} | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | select-object Display
      Name,TotalItemSize,ItemCount,LastLogonTime,LastLog gedOnUserAccount,ObjectClass,ServerName | export-csv c:\test.csv
      Basically replacing the "ft" command with "Select-Object" and removing formatting expressions.

      One more question, the TotalItemSize field gives the values as "####B" with the "B" indicating bytes. Can this be removed?

      Thanks
      |
      +-- JDMils
      |
      +-- Regional Systems Engineer, DotNet programmer & Jack of all trades
      |

      Comment


      • #4
        Re: Report on all mailbox sizes and last logon piped to CSV

        I have used this script successfully -- please feel free to adapt
        Code:
        #Get-ExchangeStats.ps1
        #T Jones June 2010
        
        $c+= get-date -format ddMMyy
        $c+= "_"
        get-mailbox | get-mailboxstatistics | 
        select-object servername, databasename,  DisplayName, @{expression={$_.TotalItemSize.Value.ToKB()}},StorageLimitStatus,LastLogonTime, LastLoggedOnUserAccount,ItemCount, DeletedItemCount, legacydn   | 
        export-csv -path ("d:\logs\"+$c+"exchangeuserstats.csv")
        Tom Jones
        MCT, MCSE (2000:Security & 2003), MCSA:Security & Messaging, MCDBA, MCDST, MCITP(EA, EMA, SA, EDA, ES, CS), MCTS, MCP, Sec+
        PhD, MSc, FIAP, MIITT
        IT Trainer / Consultant
        Ossian Ltd
        Scotland

        ** Remember to give credit where credit is due and leave reputation points where appropriate **

        Comment

        Working...
        X