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

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -