Get-ExportedFunction.ps1
19 Sep 2025Description
Purpose
Output the commands exported by a specified Module or all currently imported Modules.
Detailed Description
This function lists all the commands exported by a specified Module. If no Module is specified, it lists all the commands from all currently imported Modules.
Usage
Example 1
Get-ExportedFunction -Module 'ModuleName'
Example 2
Get-ExportedFunction
Notes
No additional notes.
Script
function Get-ExportedFunction {
<#
.SYNOPSIS
Output the commands exported by a specified Module or all currently imported Modules.
.DESCRIPTION
This function lists all the commands exported by a specified Module. If no Module is specified,
it lists all the commands from all currently imported Modules.
.EXAMPLE
Get-ExportedFunction -Module 'ModuleName'
.EXAMPLE
Get-ExportedFunction
#>
param(
[String]$Module
)
if ($Module) {
# Get commands from the specified Module
$ModuleObj = Get-Module -Name $Module
if (-not $ModuleObj) {
throw "Module '$Module' is not currently imported."
}
$functions = $ModuleObj.ExportedCommands.Values.Name
if (-not $functions) {
throw "Failed to determine exported commands for: $Module"
}
# Output as objects
foreach ($function in $functions) {
[PSCustomObject]@{
Module = $Module
Function = $function
}
}
}
else {
# Get commands from all currently imported Modules
$allModules = Get-Module
if (-not $allModules) {
throw "No Modules are currently imported."
}
foreach ($mod in $allModules) {
$functions = $mod.ExportedCommands.Values.Name
if ($functions) {
foreach ($function in $functions) {
[PSCustomObject]@{
Module = $mod.Name
Function = $function
}
}
}
else {
[PSCustomObject]@{
Module = $mod.Name
Function = "No exported commands"
}
}
}
}
}
Download
Please feel free to copy parts of the script or if you would like to download the entire script, simply click the download button. You can download the complete repository in a zip file by clicking the Download link in the menu bar on the left hand side of the page.
Report Issues
You can report an issue or contribute to this site on GitHub. Simply click the button below and add any relevant notes. I will attempt to respond to all issues as soon as possible.