Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell: How to output List content as table?

Tags:

powershell

I have an arraylist of objects, but I want to output them to the console in a tabular format like Get-Process does for processes.

How can I output a List as a Table?

Format-Table just throws an error

$bulidsList | Format-Table -Auto -InputObject $bulidsList

"The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input"

like image 505
user5855178 Avatar asked Sep 20 '25 12:09

user5855178


1 Answers

You mentioned in the question "An arraylist of objects". Here is a simple test to show you how those used with Format-Table:

$a = @()
$a += [pscustomobject]@{a = 1; b = 2}
$a += [pscustomobject]@{a = 3; b = 4}
$a += [pscustomobject]@{a = 5; b = 6}

$a | Format-Table

Here is the output:

a b
- -
1 2
3 4
5 6
like image 110
Micky Balladelli Avatar answered Sep 22 '25 05:09

Micky Balladelli