Using Show-ObjectTree to browse PowerShell Objects

You can use Get-Member to discover all Methods and Properties when working with Variables. But browsing them in your PowerShell Terminal is easier using Show-ObjectTree. In this small blog post, I’m having a busy week and preparing for my WorkplaceNinjasNL session next week, I will show you how that cmdlet works 🙂

What is Show-ObjectTree?

It’s a Cmdlet that is part of the “Microsoft.PowerShell.ConsoleGuiTools” Module (Which is compatible with PowerShell v7.2+) that allows objects to be viewed in a tree view window similar to Out-ConsoleGridView, which you can navigate using Tab (Switch from Filter to Objects), the arrow keys on your keyboard or mouse. More information about the ConsoleGuiTools module can be found here: https://github.com/PowerShell/ConsoleGuiTools

Installing Microsoft.PowerShell.ConsoleGuiTools

To install the module, you can run this in a PowerShell v7.2+ console:

Install-Module Microsoft.PowerShell.ConsoleGuiTools -Scope CurrentUser

Using Show-ObjectTree

When the module is installed, you can use Show-ObjectTree to either output piped data or input it from an InputObject (For existing variables). For example, running this will list all running processes on your system in a filterable tree view:

Get-Process | Show-ObjectTree

In the output above, the processes are shown as Objects that you can expand using the right arrow key. This will show all the Properties with their values, and you can expand those again.

If you use Tab, you will jump into the Filter option, and in the example below, I filtered for all processes containing AMD on my device: (And yes, StreAMDdeck is also listed because I have one attached to my laptop 😀 )

In the examples above, I piped the information from Get-Process to the Show-ObjectTree cmdlet. However, you can also view existing variables using the -InputObject parameter. In the example below, I stored all Windows Services on my system in a $Services Variable and use this to browse through them:

$Services=Get-Service
Show-ObjectTree -InputObject $Services

This will look something like this:

You can browse through them and see all the Properties and methods, and the type names are String, for example.

Use Escape to close the Show-ObjectTree pane.

Parameters

There are a few additional Parameters which you can use:

NAME
    Show-ObjectTree

SYNTAX
    Show-ObjectTree [-InputObject <psobject>] [-Title <string>] [-Filter <string>] [-MinUI] [-UseNetDriver] [<CommonParameters>]


PARAMETERS
    -Filter <string>
        Pre-populates the Filter edit box, allowing filtering to be specified on the command line. The filter uses regular expressions.

        Required?                    false
        Position?                    Named
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        Accept wildcard characters?  false

    -InputObject <psobject>
        Specifies the input pipeline object

        Required?                    false
        Position?                    Named
        Accept pipeline input?       true (ByValue)
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        Accept wildcard characters?  false

    -MinUI
        If specified no window frame, filter box, or status bar will be displayed in the GUI.

        Required?                    false
        Position?                    Named
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        Accept wildcard characters?  false

    -Title <string>
        Specifies the text that appears in the title bar of the Out-ConsoleGridView window. y default, the title bar displays the command that invokes Out-ConsoleGridView.

        Required?                    false
        Position?                    Named
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        Accept wildcard characters?  false

    -UseNetDriver
        If specified the Terminal.Gui System.Net.Console-based ConsoleDriver (NetDriver) will be used.

        Required?                    false
        Position?                    Named
        Accept pipeline input?       false
        Parameter set name           (All)
        Aliases                      None
        Dynamic?                     false
        Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https://go.microsoft.com/fwlink/?LinkID=113216).


INPUTS
    System.Management.Automation.PSObject


OUTPUTS
    System.Object

ALIASES
    shot


REMARKS
    None

Wrapping up

And that’s how you can browse and discover the properties, values, methods, etc. of an Object. Have a lovely weekend!

2 thoughts on “Using Show-ObjectTree to browse PowerShell Objects

  1. As always, thanks for the interesting article.
    I wasn’t aware I had so many versions of PS 7 (7.4.6.0 -x64, 7.6.4.0 -x64, 7-x64, 7-x86). If I understood ChatGPT correctly, any of these can be deleted but PS 5.1 must remain.
    Dan

    1. Yes, 5.1 is still default in the OS and any other v7 can run next to that. But 7.2/7.4/etc. Are installed in the same program files folder, so there’s only one active of those. The preview one has it’s own subfolder

Leave a Reply to Harm VeenstraCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.