powershell Exchange command with subject before RRS feed

  • Question

  • Hello,

    I would like to execute a command in Exchange powershell. 

    The command is:

    [foreach ($mail in (Get-Content 'C:\temp\UserID.txt')) {Add-Content 'c:\temp\mailboxes.txt'-value $mail ; get-mailboxFolderStatistics -Identity domain\$mail | select Name,FolderSize,FolderAndSubfolderSize,ItemsInFolder}

    The command get User IDs from the txt file and put the ID in $mail. After then the command will be execute. I only want to get the output from the command in a textfile starting with the current value of the $mail. Is that possible?

    Tuesday, October 16, 2018 10:32 AM

All replies

  • The code does not do anything.  The command "get-mailboxFolderStatistics " does not return those values.

    Look in the Gallery for scripts that get mailbox statistics and can get folder statistics.

    Please carefully review the following links to set your expectation for posting in  technical forums.

    This Forum is for Scripting Questions Rather than script requests


    Tuesday, October 16, 2018 11:11 AM
  • use select with expression to include the id from your text file

    Please remember to mark the replies as answers if they helped.

    • Edited by Proed Tuesday, October 16, 2018 11:14 AM
    Tuesday, October 16, 2018 11:14 AM
  • This is not correct. The command will do the right thing if I put the commands in the right order. I'm not the powershell guy, but I think I'm almost on the right way. 
    Tuesday, October 16, 2018 11:20 AM
  • Mailbox Statistics do not have the properties you are asking for,'

    This is what that command returns:

    PS D:\scripts> Get-MailboxStatistics jsmith|select *
    RunspaceId                                     : f3b19b6b-e26d-46ad-a095-25b29530600f
    MoveHistory                                    :
    AssociatedItemCount                            : 275
    DeletedItemCount                               : 0
    ItemCount                                      : 788
    TotalDeletedItemSize                           : 0 B (0 bytes)
    TotalItemSize                                  : 34.31 MB (35,973,326 bytes)
    MessageTableTotalSize                          : 16.78 MB (17,596,416 bytes)
    MessageTableAvailableSize                      : 2.406 MB (2,523,136 bytes)
    AttachmentTableTotalSize                       : 17.78 MB (18,644,992 bytes)
    AttachmentTableAvailableSize                   : 448 KB (458,752 bytes)
    OtherTablesTotalSize                           : 3.531 MB (3,702,784 bytes)
    OtherTablesAvailableSize                       : 1.75 MB (1,835,008 bytes)
    IsEncrypted                                    : False
    DataEncryptionPolicyId                         :
    KeyVersionIDs                                  :
    AdvancedDataEncryptionDetails                  :
    CurrentSchemaVersion                           : 1.1
    DisconnectDate                                 :
    DisconnectReason                               :
    DisplayName                                    : John Smith
    LastLoggedOnUserAccount                        :
    LastLogoffTime                                 :
    LastLogonTime                                  : 10/16/2018 6:27:05 AM


    • Edited by jrv Tuesday, October 16, 2018 11:23 AM
    Tuesday, October 16, 2018 11:23 AM
  • Yes you are right and that's why I need in addition a headline with the current UserID
    Tuesday, October 16, 2018 11:26 AM
  • Your code and question make no sense.


    Tuesday, October 16, 2018 11:35 AM
  • This command solved it. Maybe not the best solution but now I'm able to difference between the UserIDs by using the Identity.

    foreach ($UserID in (Get-Content 'C:\temp\UserID.txt')) {get-mailboxFolderStatistics domain\$UserID | select Identity,ItemsInFolder,Name,FolderSize >> C:\temp\mailboxes.txt}

    Thanks for the help!

    Tuesday, October 16, 2018 7:34 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    Best Regards,


    Just do it.

    Wednesday, November 7, 2018 7:42 AM