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

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -