---
title: "PowerShell Functions vs. Cmdlets: Difference?"
description: "Learn the key differences between PowerShell commands, functions, and cmdlets. Understand when to use each one and how to inspect their code and functionality."
canonical: "https://adamtheautomator.com/powershell-commands-vs-cmdlets/"
---

# PowerShell Functions vs. Cmdlets: Difference?

> Learn the key differences between PowerShell commands, functions, and cmdlets. Understand when to use each one and how to inspect their code and functionality.

Source: https://adamtheautomator.com/powershell-commands-vs-cmdlets/

---

ATA Learning

Tap to hide

[

ATA Learning

](/)

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Search for:  

*   [](https://twitter.com/adbertram)
*   [](https://github.com/Adam-the-Automator)
*   [](https://www.linkedin.com/company/adam-the-automator-llc)
*   [](/feed/)

![PowerShell Functions vs. Cmdlets: Difference?](https://adamtheautomator.com/wp-content/uploads/2024/11/image-25.png)

# PowerShell Functions vs. Cmdlets: Difference?

[![](https://secure.gravatar.com/avatar/d0b9d42e21e5622713f8b693aa5c0f9244d5f7dd200ed29b8398f52dee5de337?s=192&d=mm&r=g)Adam Bertram](https://adamtheautomator.com/author/adam-bertram/)7 November 20241 min. read

Categories: [IT Ops](/category/it-ops/)

Tags:[PowerShell](/tag/powershell/)

Whenever you execute or run anything in PowerShell, you’re running a “command.” A command is an informal term for executable code, which can be a built-in PowerShell cmdlet, a custom function, or even an object method.

Cmdlets are compiled executable code provided by Microsoft, created in a language like C#, compiled, and added to a PowerShell module by software developers. Functions, on the other hand, are created directly in PowerShell by users. Although functions and cmdlets are technically different, they can be thought of as similar when you’re starting out.

To demonstrate functions vs. cmdlets, let’s dig in with a short demo. Let’s find all of the available commands in the current session:

```
## Find all of the available command types
Get-Command | Group-Object -Property CommandType
```

![](https://adamtheautomator.com/wp-content/uploads/2024/11/2024-11-03_13-33-59-1024x188.png)

_**People often interchange the terms commands, cmdlets, and functions. If this becomes confusing, remember that a “command” generally refers to either a cmdlet or a function.**_

The `Group-Object` cmdlet groups properties, and here it provides a summary of commands by type.

You’ll see command types like aliases, cmdlets, and functions. Let’s inspect the code behind one of the cmdlets:

```
Get-Command -Name Get-Content | select -ExpandProperty Definition
```

![](https://adamtheautomator.com/wp-content/uploads/2024/11/image-35-1024x293.png)

The `Definition` property contains the code for a function, and parameter sets for a cmdlet. In the case of cmdlets, you’ll only see parameter sets.

_**While cmdlets are more optimized for performance due to their precompiled nature, functions offer flexibility. For tasks involving custom logic or data processing, functions allow you to go beyond what cmdlets can do, providing room for creativity and problem-solving.**_

Now, let’s inspect a function:

```
Get-Command -Name Add-BitLockerKeyProtector | select -ExpandProperty Definition
```

![](https://adamtheautomator.com/wp-content/uploads/2024/11/image-36-1024x296.png)

You can see the actual PowerShell code for functions.

If you wish to see the module that a function resides in, you can look at the `Source` property:

```
Get-Command -Name Add-AzADAppPermission
```

![](https://adamtheautomator.com/wp-content/uploads/2024/11/2024-11-03_13-35-50-1024x115.png)

To locate the module, use:

```
Get-Module -Name BitLocker | select Path
```

![](https://adamtheautomator.com/wp-content/uploads/2024/11/2024-11-03_13-36-14-1024x131.png)

This command will show the module’s path. For example, if the module is located in `/Users/adam/.local/share/powershell/Modules/Az.Resources/7.4.0/Az.Resources.psm1`, you can open it in VS Code for further inspection.

```
code '/Users/adam/.local/share/powershell/Modules/Az.Resources/7.4.0/Az.Resources.psm1'
```

Inside the module, you’ll find several functions written in PowerShell, which you can explore and modify as needed.

It’s important to remember that although cmdlets tend to perform better, especially with large datasets, functions can be more versatile. They allow for the creation of custom workflows and logic that aren’t possible with cmdlets alone.

When deciding between using a cmdlet or a function, think about the task at hand. Cmdlets are ideal for built-in tasks that are already optimized, but if you need more control or customization, functions are your best bet. Functions can help create reusable code blocks, streamline complex tasks, and enhance overall script modularity.

Share this article

[Share on X](https://twitter.com/intent/tweet?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-commands-vs-cmdlets%2F&text=PowerShell%20Functions%20vs.%20Cmdlets%3A%20Difference%3F)[Share on Facebook](https://www.facebook.com/sharer/sharer.php?u=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-commands-vs-cmdlets%2F)[Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fadamtheautomator.com%2Fpowershell-commands-vs-cmdlets%2F)

## Related Posts

![](https://adamtheautomator.com/wp-content/uploads/2026/06/26995-troubleshoot-dns-issues-powershell-codex.webp)

### [Troubleshoot DNS Issues with PowerShell](/troubleshoot-dns-issues-powershell/)

Troubleshoot DNS issues with PowerShell by testing name resolution, DNS client settings, cache entries, and network connectivity in a repeatable workflow.

![](https://adamtheautomator.com/wp-content/uploads/2025/10/image_2025-10-24_095322075.png)

### [Migrating from PowerShell 6 to 7.5: Breaking Changes/New Features](/migrating-powershell-6-to-7-5/)

Migrate from PowerShell Core 6 to 7.5: breaking changes, features, and testing tips.

![](https://adamtheautomator.com/wp-content/uploads/2025/06/featured-image-6.png)

### [How to Add Timeouts to Pester Tests with PowerShell Runspaces](/pester-test-timeout-runspaces/)

Prevent Pester tests from hanging indefinitely using PowerShell runspaces. Learn to handle variable scoping, module loading, TestDrive access, and stream capture challenges with timeout protection.

## Categories

*   [IT Ops](/category/it-ops/)
*   [Cloud](/category/cloud/)
*   [DevOps](/category/devops/)
*   [Home Ops](/category/home-ops/)
*   [Information Security](/category/infosec/)
*   [Software Development](/category/software-development/)

## Site

*   [Home](/)
*   [Tutorials](/tutorials/)
*   [Instructors](/author/)
*   [Advertising](/advertising/)
*   [Recommended Resources](/resources/)
*   [About Adam](/about-adam/)

Copyright 2026© ATA Learning | [Privacy Policy](/privacy/)
