Skip to content

Instantly share code, notes, and snippets.

@drlsdee
Last active October 24, 2023 14:32
Show Gist options
  • Save drlsdee/7cf272b0341c1c9c14bd003c82976f4c to your computer and use it in GitHub Desktop.
Save drlsdee/7cf272b0341c1c9c14bd003c82976f4c to your computer and use it in GitHub Desktop.
Simply displays a summary of the cmdlets and functions exported from the PowerShell module.
<#
.SYNOPSIS
Simply displays a summary of the cmdlets and functions exported from the PowerShell module.
.DESCRIPTION
Simply displays a summary of the cmdlets and functions exported from the PowerShell module.
.EXAMPLE
PS C:\> Get-Module -Name 'Microsoft.PowerShell.Utility' | Show-PSModuleCommand | Format-Wide -GroupBy Verb -Column 6
Displays a summary of the cmdlets and functions exported from the PowerShell module "Microsoft.PowerShell.Utility".
.INPUTS
[psmoduleinfo]
.OUTPUTS
[psobject]
.NOTES
Simply displays a summary of the cmdlets and functions exported from the PowerShell module.
.LINK
https://gist.github.com/drlsdee/7cf272b0341c1c9c14bd003c82976f4c
#>
function Show-PSModuleCommand {
[CmdletBinding()]
param (
[Parameter(Mandatory, ValueFromPipeline, Position=0, ParameterSetName='ModuleInfo')]
[psmoduleinfo]$ModuleInfo,
[Parameter(Mandatory, Position=0, ParameterSetName='ModuleName')]
[string]$Name,
[Parameter(ParameterSetName='ModuleName')]
[switch]$ListAvailable,
[Parameter()]
[string[]]$Properties = @(
'Name', 'Verb', 'Noun', 'CommandType', 'ModuleName', 'Version'
)
)
begin {}
process {
if (-not [string]::IsNullOrEmpty($Name)) {
return Get-Module -ErrorAction Stop -Name $Name -ListAvailable:$ListAvailable | Show-PSModuleCommand
}
$ModuleInfo.ExportedCmdlets, $ModuleInfo.ExportedFunctions | `
Select-Object -ExpandProperty Values -ErrorAction Stop | `
Select-Object -Property $Properties -ErrorAction Stop
}
end {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment