Exploring PowerShell Modules

by Aug 31, 2018

Most cmdlets and functions are part of PowerShell modules. If you’d like to explore where exactly these commands come from, here is an easy approach.

# replace the command name with any PowerShell command name
# you'd like to explore
$Name = "Get-Printer"
$ModuleName = (Get-Command -Name $Name -CommandType Function, Cmdlet).Source

if ('' -eq $ModuleName)
{
    Write-Warning "$Name was defined in memory, no module available."
    return
} 

Write-Warning "$Name resides in $ModuleName module"

$module = Get-Module -Name $ModuleName -ListAvailable
explorer $module.ModuleBase

Simply change $Name to the name of any PowerShell cmdlet you’d like to explore. If the command resides in a PowerShell module, the module opens in Windows Explorer, and you can examine its content.

Twitter This Tip! ReTweet this Tip!