Display the Properties of an Item As a List

1. Problem

You have an item (for example, an error record, directory item, or .NET object), and you want to display detailed information about that object in a list format.

2. Solution

To display detailed information about an item, pass that item to the Format-List cmdlet. For example, to display an error in list format, type the commands:

        $currentError = $error[0]
        $currentError | Format-List -Force


3. Discussion

The Format-List cmdlet is one of the three PowerShell formatting cmdlets. These cmdlets include Format-Table, Format-List, and Format-Wide. The Format-List cmdlet takes input and displays information about that input as a list. By default, PowerShell takes the list of properties to display from the *.format.ps1xml files in PowerShell’s installation directory. To display all properties of the item, type Format-List *. Sometimes, you might type Format-List * but still not get a list of the item’s properties. This happens when the item is defined in the *.format.ps1xml files, but does not define anything to be displayed for the list command. In that case, type Format-List-Force.

Tags: , , , , , ,