Skip to main content desktop
Try Now

Viewing PowerShell Function Contents

Kris PowellKris Powell

Have you ever thought to yourself, "Self… how does this PowerShell function work?" If you have, then you're in luck! With PowerShell, it's super simple to view Function contents.

In fact, we're going to show you a few different ways to display that info.

So, hold on to your chairs and your monocles! Let's dive right in and find out more!

Identifying PowerShell functions

First, we need to identify a function to peek at.

For this exercise, I have selected the command Pause for its simplicity. Before we proceed, let's verify that this command is truly a function.

Get-Command Pause

Since we verified that it's a function, let's see what the function Pause is actually doing under the hood.

Viewing function contents

Here are 3 different ways to view function contents. You can pick and choose which method works best for you.

Method 1 - Using Get-Command

Get-Command <Function Name> | Select -ExpandProperty ScriptBlock


(Get-Command <Function Name>).ScriptBlock

Ta da! That's it!

Get-Command Pause | Select -ExpandProperty ScriptBlock

So, it looks like the function Pause runs the following command:

$null = Read-Host 'Press Enter to continue…'

How fancy!

Method 2 - Using $function

Another fancy way to see the contents of the pause function is to use the following:


So simple, so wonderful.

Method 3 - Using the Function: Drive

Functions are automatically stored in the Function: Drive. You can see this yourself by typing: Get-PSDrive

Since this is a drive, we can browse it with Get-ChildItem. Get-ChildItem Function:Pause | Select *

Now we can see the contents of all functions should we so desire.

Showing all available Functions

In order to see all available functions, you could run this command. You will see a lot of results.

Get-Command -CommandType Function

Wrapping Up

One thing to note is that this will only work for functions. If you want to know what cmdlets are doing, you can go take a look at the PowerShell open source project on GitHub (link here).

Have fun and happy PowerShelling!

Too see this in action, please enjoy this short video:

This blog post is part of a series on PowerShell:

Ready to put the PowerShell Scanner through its paces?

Take our 14-day Free Trial. Feel the power of the PowerShell scanner.
Start a Trial

Don't miss the next post!

How to Block the Windows 11 Upgrade

Windows 11 is here, but that doesn't mean you have to use it. Discover several different ways to block Windows 11 from installing on your computers.

© 2021 Corporation
  • PDQ Deploy ®
  • PDQ Inventory ®
  • Pricing
  • Downloads
  • Licensing
  • Buy