How to create PowerShell custom tables

You can display standard PowerShell output information or create custom tables.

I mean, if you execute get-wmiobject command for Win32_PysicalMemory class;

image

That’s the default design of output.But with select-object or format-table parameters you can filter for specific columns.

image

Format-table filters for only speed and manufacturer columns.

But what if you want to create your own tables and columns? In PowerShell it’s so simple .

Let’s create one;

$MyTable = @{Expression={$_.speed};Label=”Memory Speed”;width=15},

@{Expression={$_.manufacturer};Label=”Vendor”;width=15}

With this command , I created a variable and combine it with new column names.

$_.speed and $_.manufacturer are the existing column values.I changed label names which I want ones.

Now if I execute following script;

image

That’s the output;

image

columns names is replaced with my custom label names.

You can develop more advanced scripts through these simple examples.

Leave a Reply

Your email address will not be published. Required fields are marked *

+ 65 = 69