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
Post a Comment