You are not logged in.

#1 01 Apr 2019 20:49

xcabur
New Member
Registered: 23 Oct 2018
Posts: 4

Change default output to format-list

Hi, i have a simple function like this:

function Test-A{
    $out = [pscustomobject]@{
        Name = "Test"
        Value  = "1"
        Value1  = "1"
        Value2  = "1"
    }
    $out
}

Test-A

$out is formatted as a table by default. But I prefer the list format.  Also the output should follow the pipline unformatted for further processing. I can't use $out | fl, because the output format should be affected from outside the function. E.g. test-a | ft or test-a | out-gridview. This would be in conflict with fl within the function.
If there are more than five properties, the output automatically changes to list form. However, I have fewer properties. Can I change the default output format to the list format myself?

thanks a lot

best regards

Offline

#2 26 Sep 2020 15:40

Simon Sheppard
Admin
Registered: 27 Aug 2005
Posts: 1,130
Website

Re: Change default output to format-list

Here's a worked example of setting the Default Property Display
https://learn-powershell.net/2013/08/03 … m-objects/

Offline

Board footer

Powered by