powershell - Why does a hash table formatting change automatically? -
powershell - Why does a hash table formatting change automatically? -
i want know why removing comment tag 'nextrun' property in hash table in below code causes default formatting switch table list.
$a=get-scheduledtask|sort state` $b=$a|get-scheduledtaskinfo` ($i=0; $i -lt $a.count;$i+=1)` {$props=@{'name' =$a[$i].taskname; 'description'=$a[$i].description; 'state' =$a[$i].state; #'nextrun' =$b[$i].nextruntime; 'lastrun' =$b[$i].lastruntime} $obj = new-object -typename psobject -property $props $obj}`
or, there different object type prevent happening ?
when outputting object properties without formatting cmdlet, powershell looks @ number of properties determine if it's going utilize table or list. in experience, 5 or more properties auto-format list, less auto-format table.
in case need utilize formatting cmdlet impact output formatting, or output less properties alter auto-formatting.
powershell formatting hashtable powershell-v4.0
Comments
Post a Comment