Windows PowerShell Format-List Cmdlet

Windows PowerShell Scripting - Format-List (fl)

Format-List, or FL for short, allows PowerShell to control the output of your main script.  Whenever presentation of information is important, pipe the script's output into Format-List (or Format-Table).PowerShell Format-list

On this page I will show you examples of this straightforward, but important command.

Windows PowerShell Format-List Topics


Format-List - Simple Examples

Scenario: We wish to investigate the DHCP service running on workstation or a Windows Server.

PowerShell and .Net framework are installed on your computer.
You are at the prompt PS>  Or if you have PowerShell 2.0 or later, launch the ISE.

Example 1a
Let us get started with an example using the default formatting:

# Preliminary example no Format-List yet

The 'problem' is that we want to home in on just the DHCP service, furthermore we want to display more properties.

PowerShell Format-list

Example 1b
Now let me introduce Format-List so that we can better control the output.

# Example of PowerShell Format-List
Get-Service DHCP | Format-List

PowerShell Format-list

Note 1:  Thanks to Format-List we now have information about DHCP that we needed.

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds' Network Performance Monitor will help you discover what's happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds' Network Performance Monitor

Troubleshooting Format-ListPowerShell Format-list

About the only thing that can wrong with Format-List is forgetting the pipe (|) before the command.  The secret is to get the main command working then use (|) to pipe the output into Format-List.  From there you list the names of the properties you wish to display.

For many cmdlets, especially those with more than 5 properties, Format-List is the default method of displaying the data. Thus it's often a case of, 'How do I choose the properties or columns and then display them with Format-Table', this is especially true when working with Get-WmiObject classes.

Format-List Alias FL

With Microsoft, there are always at least three ways of doing everything, what seems like redundancy when you are an expert, seems like perspective when you are a beginner.  One obvious example is that you can abbreviate Format-Table to ft.  As you increase your range of PowerShell commands, keep an eye out for another PowerShell Alias, for example gci (Get-Childitem).

Here are alternative methods of achieving the above objectives, each example is designed to develop your binocular vision, hence see the target more clearly.  For example, if you experiment with format-wide and Format-Table you will extend your range of formatting options.

Examples of PowerShell FL Alias of Format-List

Example 1 Using Get-Service

# Example of PowerShell Format output with FT
Get-Service | Where {$_.status -eq 'Running'} | FL Name, CanShutdown

Learning points.  You can substitute FL for Format-List.  Actually, lower-case fl works just as well, I use the capital form because l could be mistaken for I.  You can also use this as an opportunity to reduce the number of properties displayed in the output.

Example 2 Get-Member

Get-Service | Get-Member -Membertype method | fl name

Learning points.  In addition to property, you can research an object's method.  For instance, in other scripts you may wish to employ the .kill() method.

Example 3 Real-Life Example to Detect Rogue .exe Files

Scenario, you want check C:\Windows for non-Microsoft files.

Step 1 Research File Properties

Get-ChildItem C:\Windows\notepad.exe | Get-Member -Membertype Properties

Step 2 Focus on VersionInfo with PowerShell Fl

Get-ChildItem C:\Windows\*.exe |
Where {$_.VersionInfo.LegalCopyright -Notmatch 'Microsoft'} | fl VersionInfo

Learning Points.  This script will list all executables in the Windows folder that don't belong to Microsoft.  I thank Gary Mitchell for sending this PowerShell script.

Note 2: Out-GridView: PowerShell v 2.0 introduces a new cmdlet to control data display.  See more on how to pipe the results into out-GridView.

Engineer's Toolset v10Guy Recommends: SolarWinds Engineer's Toolset v10

This Engineer's Toolset v10 provides a comprehensive console of 50 utilities for troubleshooting computer problems.  Guy says it helps me monitor what's occurring on the network, and each tool teaches me more about how the underlying system operates.

There are so many good gadgets; it's like having free rein of a sweetshop.  Thankfully the utilities are displayed logically: monitoring, network discovery, diagnostic, and Cisco tools.  Try the SolarWinds Engineer's Toolset now!

Download your fully functional trial copy of the Engineer's Toolset v10

PowerShell Format-List Parameters

# Extra parameters for PowerShell to Format output
Get-Help Format-List -full

One of my favourite Format-Table parameters is -GroupBy

Format-Table - Simple Examples

Scenario: we wish to investigate processes running on workstation or a Windows Server.

Example 1a
Let us get started with an example using the default formatting:

# Preliminary example no Format-Table yet

The 'problem' is that the name of the process is on the right, and we have columns in the output which are of no interest.

PowerShell Format-Table

Example 1b
Now let me introduce Format-Table so that we can control which properties to display in the output.  Let us suppose that we are only interested in 'Handles'.

# Example of PowerShell Format-Table
Get-Process | Format-Table ProcessName, handles -auto

PowerShell Ft

Note 3:  Thanks to Format-Table we now have the name of the process in the first column.

Note 4: -auto prevents the output spreading to the full width and consequently, the -auto parameter makes the figures easier to read.  To see the effect try the above command without -auto.

Guy Recommends:  SolarWinds' Free Bulk Import ToolFree Download Solarwinds Bulk Import Tool

Import users from a spreadsheet.  Just provide a list of the users with their fields in the top row, and save as .csv file.  Then launch this FREE utility and match your fields with AD's attributes, click and import the users.

Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.

If you need more comprehensive application analysis software,
Download a free trial of SAM (Server & Application Monitor)


How to Discover More Formatting Cmdlets

Get-Command -verb format

In addition to format-List, you can display data in not one column but two or three columns.  This is the format-wide or (fw) option, which is useful where you have a long list with only one field, for example:

Get-Process | Get-Member -Membertype method | Format-Wide name -column 3.

See more on PowerShell's Format Table ยป

Summary of Format-List in Windows PowerShell

Presentation really does transform the output of your PowerShell scripts.  Also, when you get too much information the answer is to filter and reduce the number of columns in the display.  On other occasions, you need to display extra properties, which are not shown by the default command.  In each case, Format-Table gives you control over the presentation of your output.

While format-List (or FL for short), is a ubiquitous command, it does have numerous switches. With judicious application of its many switches, you can produce creative and effective outputs.

If you like this page then please share it with your friends


See more Microsoft PowerShell output tutorials:

PShell Home   • Out-File   • Out-GridView   • ConvertTo-Csv   • ConvertTo-Html   • ConvertFrom-Csv

Tee-Object   • Import-CSV   • Format-Table   • PowerShell Here-String  • ConvertFrom-JSON

Export-CliXml   • Format-List   • Read-Host    • PowerShell Get-History   • -f format   • Pipe to file

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.



Custom Search

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

Windows Management Instrumentation (WMI) is most useful for PowerShell scripting.

SolarWinds have produced this Free WMI Monitor to take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2016 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: