Prof. Powershell

Wide Load

Get a better view of the data you've asked PowerShell to fetch with the Format-Wide cmdlet.

If you've used PowerShell 1.0 for any length of time you are most likely comfortable with Format-Table and Format-List. Those cmdlets are great when you have several object properties to view. However, there may be times when you only need a single piece of information. Try this:

Get-service | Where {$_.status -eq "Running"} | Select Name

You'll end up with a long list which can be a nuisance. A better solution would be to get all the services in one screen without any scrolling. To accomplish that, use Format-Wide, which has an alias of fw. All you need to specify is a property name to display:

Get-service | Where {$_.status -eq "Running"} | format-wide Name

The default will be a two-column display which may be more than sufficient. But you can specify the number of columns:

Get-process | format-wide -column 3

Or if you prefer, you can let the cmdlet squeeze in as much information by using the -autosize parameter:

Get-process | format-wide -autosize

Like the other formatting cmdlets, you can create a complex pipelined expression:

dir $env:temp -rec | sort Extension | format-wide Name -groupby extension -autosize

This command is recursively listing the %TEMP% directory, sorting all of the files by extension. The file objects are then piped to Format-Wide, which groups the output by extension and autosizes the output. Depending on the filenames, some extensions might have three columns and some might have eight. But the end result is a concise listing without requiring you to scroll backwards through many pages.

The next time you have a lot of information to look at quickly, think wide load. For more information, look at the cmdlet's help.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular

SharePoint Watch

Sign up for our newsletter.

Terms and Privacy Policy consent

I agree to this site's Privacy Policy.