locked
Get a report joining data from Get-MailBox and Get-MailBoxStatistics RRS feed

  • Question

  • Hi

    I have 2 cmdlets, and every has different information of the same users, the point is that I have to get the information of every cmdlet  and in excel I have to join the information

    Is there a way to get both information joined in one shot?

    This is one cmdlet:

    Get-Mailbox -Server MB05 | Select-Object DisplayName,SamAccountName,UserPrincipalName,UseDatabaseRetentionDefaults,OrganizationalUnit,PrimarySmtpAddress,WhenCreated,WhenChanged,HiddenFromAddressListsEnabled,@{N="AddressListMembership";E={ $_.AddressListMembership -JOIN ';'}},UseDatabaseQuotaDefaults,ForwardingAddress,DeliverToMailboxAndForward,RecipientLimits,ManagedFolderMailboxPolicy,@{N="GrantSendOnBehalfTo";E={ $_.GrantSendOnBehalfTo -JOIN ';'}},MaxSendSize,MaxReceiveSize,Database | Export-CSV -Path d:\ms\mb05.txt -Delimiter "`t"  -Encoding Unicode -NoTypeInformation

    This is the other cmdlet:

    Get-MailboxStatistics Server MB05| Select-Object DisplayName,Database,StorageLimitStatus,@{label="Total Size (MB)";expression={$_.TotalItemSize.Value.ToMB()}},@{label="Total Delete (MB)";expression={$_.TotalDeletedItemSize.Value.ToMB()}}, ItemCount,DeletedItemCount,LastLogoffTime,@{label="ProhibitSendQ (MB)";expression={$PSQ}}| Export-CSV -Path d:\ms\ms05a.txt -Delimiter "`t" -Encoding Unicode -NoTypeInformation

    Thank you in advanced.


    Doc MX

    Thursday, March 6, 2014 9:01 PM

Answers

All replies

  • I think something like this would work:

    $stuff = @()
    
    Get-Mailbox -ResultSize unlimited -Database MB05| foreach{
     $x = "" | select `
      DisplayName, `
      SamAccountName, `
      UserPrincipalName, `
      UseDatabaseRetentionDefaults, `
      OrganizationalUnit, `
      PrimarySmtpAddress, `
      WhenCreated, `
      WhenChanged, `
      HiddenFromAddressListsEnabled, `
      AddressListMembership, `
      UseDatabaseQuotaDefaults, 
      ForwardingAddress, `
      DeliverToMailboxAndForward, `
      RecipientLimits, `
      ManagedFolderMailboxPolicy, `
      GrantSendOnBehalfTo, `
      MaxSendSize, `
      MaxReceiveSize, `
      Database, `
      StorageLimitStatus, `
      'Total Size (MB)', `
      'Total Delete (MB)', `
      ItemCount, `
      DeletedItemCount, `
      LastLogoffTime, `
      'ProhibitSendQ (MB)'
    
    
     $m = Get-Mailbox $_
      $x.DisplayName = $m.Displayname,
      $x.SamAccountName = $m.SamAccountName,
      etc.,
      etc.,
      etc.
    
     $m = Get-MailboxStatistics $_
      $x.StorageLimitStatus = $m.StorageLimitStatus,
      $x.'Total Size (MB)' = $m.TotalItemSize.Value.ToMB(),
      etc.,
      etc.,
      etc.
    
     $stuff += $x
    }
    $stuff | export-csv -Path d:\ms\mb05.txt -Delimiter "`t" -Encoding Unicode -NoTypeInformation
    


    --- Rich Matheisen MCSE&I, Exchange MVP

    Friday, March 7, 2014 2:45 AM
  • Hi,

    In order to resolve the problem more efficiently, I recommend you post to Script forum which is staffed by more experts specializing in this kind of problems to get better help.

    http://social.technet.microsoft.com/Forums/scriptcenter/en-US/home?category=scripting

    Thanks for understanding.

    Best regards,
    Belinda


    Belinda Ma
    TechNet Community Support

    • Marked as answer by cara chen Monday, March 17, 2014 8:03 AM
    Friday, March 7, 2014 7:48 AM