Search code examples
powershellazure-powershell

How to expand all columns for Get-AzReservation return array?


I am trying to get all information about my reservation and for that I use Get-AzReservation cmdlet.

It returns the 7 columns as described in the documentation.

But when I use Export-Csv and Import-Csv on that array and then check the imported array I get 56 columns.

How to show all the columns returned by the Get-AzReservation cmdlet without doing the csv step?

$reservation = Get-AzReservation -ReservationOrderId a87c1742-0080-5b4d-b953-8531ad46fdc8 -ReservationId cad6fef7-ae86-4d47-91d0-67c897934bfe

$reservation | Export-Csv -Path "res1.csv" -NoTypeInformation

$res1 = Import-Csv -Path "res1.csv"

$res1

I tried -Expand but it wants only renewProperties and returns an error.

Clearly the data is there because the csv has 56 columns but how to see it? Or at least be informed that I don't see all the columns because the documentation doesn't mention it. (| ft -Wrap from docu doesn't work)


Solution

  • Per comments, $res | format-list * will give you a vertical list of properties rather than a table, but it will show you all the properties more clearly than a 56 column table would.

    The documentation shows the default results from “stringifying” the result of Get-AzReservation - PowerShell has a bunch of configuration settings that specify whether to default to formatting output as a table or a list, and also what properties to output for individual types of objects, and in this case it shows a table containing the columns shown in the documentation.

    By using | format-list * you’re overriding the default display settings and telling PowerShell to format as a list and show all properties…