powershell - Returns objects asyn with Format-Table and a specific layout -


i want return object specific layout, each object should displayed when returned.

if run code in powershell (not ise) see result not until function ends.

function main {     ($i = 1; $i -lt 10; $i++)     {          [pscustomobject]@{index=$i; timestamp=(get-date)}         sleep -seconds 1     } }  main | format-table @{label="index"; expression={$_.index};width=10},                     @{label="timestamp"; expression={$_.timestamp};width=20} 

this works, want specific layout.

function main {     ($i = 1; $i -lt 10; $i++)     {          [pscustomobject]@{index=$i; timestamp=(get-date)}         sleep -seconds 1     } }  main  

and why behavior different if execute script in ise?

this line in powershell profile responsible behavior.

# following function automatically adds -autosize when use format-wide or format-table $psdefaultparametervalues['format-[wt]*:autosize'] = $true 

Comments

Popular posts from this blog

mysql - FireDac error 314 - but DLLs are in program directory -

git - How to list all releases of public repository with GitHub API V3 -

c++ - Getting C2512 "no default constructor" for `ClassA` error on the first parentheses of constructor for `ClassB`? -