Format-List: sort properties by name

后端 未结 8 1992
一向
一向 2021-01-17 18:02

Is it possible to sort the output of the Format-List cmdlet by property name?
Suppose that I have an object $x with two properties \"A\" and \"B\", and when I run Format

8条回答
  •  攒了一身酷
    2021-01-17 18:31

    If you are dealing with a small number of properties, you can specify their order with the -Property parameter.

    Here is an example:

    Format-List -Property Owner, Path
    

    If you have a lot of properties, I am not sure there is any easy way to sort them in Format-List, like Roman said.

提交回复
热议问题