Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

Discovering Custom PowerShell Views

Posted on October 16, 2020October 16, 2020

The other day I shared some ideas on why and how you might want to build a custom format view in PowerShell. As I mentioned in that article, PowerShell ships with a number of custom views for different types of objects.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!
Get-Process | Format-Table -view StartTime

How did I know that view existed? What other views exist that I don't know about? This has always been a complicated question to answer. Or more accurately, it is a question with a complicated answer.

In my PowerShell classes, I tell people to use a quick and dirty hack.

Force PowerShell to throw an exception. The error message (mine is in green) tells you the possible view names. You can do this trick with other format commands like Format-List. Be aware that some object types might not have any defined views for Format-List or Format-Table.

I wanted a better way and finally got around to creating it.

In the latest version of the PSScriptTools module, you will find a command called Get-FormatView. This command will display loaded views for the different format controls such as Table or List. If you run the command, the default is to show everything. But you can also specify the type name of an object.

If you pipe Get-Process to Get-Member you'll see the type name. Here's the result using Get-FormatView.

If you see multiple entries for a given format, like Table, the first one should be the default. Often you don't need to do anything. When you run Get-Process alone, the output is automatically formatted with the default view, i.e. process.

Let me load the custom format file I created the other day and re-run the command.

And there's my new view which I can use just as I showed in the earlier article.

Get-Process | Where WS -ge 100MB | Format-Table -view WS

Now you have an easy way to discover new formatting options, and I've given you a tool to easily create your own.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

3 thoughts on “Discovering Custom PowerShell Views”

  1. Alexander Kozlov says:
    October 19, 2020 at 1:57 pm

    Thanks for your work! Can you provide any tips for setting up PowerShell Terminal? Maybe you already have a video or blog post? Thanks in advance!

    1. Jeffery Hicks says:
      October 19, 2020 at 3:17 pm

      You might start with this presentation I did earlier this year. https://www.youtube.com/watch?v=jWpYK2Nd4dg

      1. Alexander Kozlov says:
        October 22, 2020 at 12:47 pm

        Great! Thanks again for your blogging. Not many IT professionals find time for this now.

Comments are closed.

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d