Search code examples
powershellwindows-server-2008exchange-serverpowershell-2.0exchange-server-2007

How do I combine multiple tables into 1 table in powershell?


In powershell I can use the Format-Table command to sort everything in my results; however I have the same script that needs to return data from four servers. I am going to build an HTML report and send it by email once I can format the table properly, but I don't want 4 tables. I want all the tables combined into one. This specifically relates to the Exchange Management Shell and replication health checks.

For examples the command Get-StorageGroupCopyStatus returns information as shown below:

Identity    SummaryCopyStatus  CopyQueueLength  ReplayQueueLength
--------    -----------------  ---------------  -----------------
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0
Server\Db   Healthy                0               0

I want to combine that output from 4 servers into one large table. What is the best way to do that in powershell?


Solution

  • Assuming you can query your servers from one central location, just execute your commands in a scriptblock and pipe the result to the convertto-html cmdlet.

    &{Get-StorageGroupCopyStatus SERVERA;Get-StorageGroupCopyStatus SERVERB} | convertto-html