Change order of columns in the object

前端 未结 4 1570
陌清茗
陌清茗 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:16

    Format-Table it's a good solution when you need to display your object fields in a specific order, but it will change the obect and you won't be able to pipe your object, for example when exporting to csv (Export-Csv).

    In the case you just want to change "the order of the fields in the object" use Select-Object. This will preserve object type and fields, and still you will be able to pipe the object to other cmdlets.

提交回复
热议问题