Formatting Output of ForEach Array
greetings folks, , happy labor day. here in japan it's tuesday already.
i'm attempting format output of items in array that:
1. rows under single set of column headers, and...
2. columns auto-sized or width restricted.
can 1 (see below example), format-table -autosize split output 2 sets of results different column headers. how can both 1 , 2 above?
example, get-queue on exchange hub servers.
foreach ($strhubs in get-exchangeserver | where-object {$_.serverrole -match "hubtransport"}) { $strque = get-queue -server $strhubs $strque | select-object identity,messagecount
}
identity messagecount
-------- ------------
server1\37240 9
server1\46206 1
server2\36977 9
server2\45119 1
adding format-table -autosize splits output to:
identity messagecount
-------- ------------
server1\37240 9
server1\46206 1
identity messagecount
-------- ------------
server2\36977 9
server2\45119 1
i use script block that:
&{ foreach ($strservers in get-exchangeserver) { test-servicehealth $strservers | select-object @{ label = "server"; expression={$strservers.name}},role,requiredservicesrunning,servicesnotrunning } } | format-table
[string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
Windows Server > Windows PowerShell
Comments
Post a Comment