Change order of columns in the object

前端 未结 4 1579
陌清茗
陌清茗 2020-12-11 18:41

How can I change the column ordering of the output my code produces:

$apps = Import-CSV apps.csv
$computers = Import-CSV compobj.csv
foreach ($computer in $c         


        
4条回答
  •  北荒
    北荒 (楼主)
    2020-12-11 19:08

    Powershell V3 added a type accelerator for [PSCustomObject] that creates objects using an ordered hash table, so the properties stay in the order they're declared:

    [PSCustomObject] @{
      Computer=$computer.hostname
      App=$app.appname
      Installed=$installed
    }
    

提交回复
热议问题