Public/Get-PwShSummitModule.ps1
|
function Get-PwShSummitModule { <# .SYNOPSIS Displays information about the PwShSummit module and its commands. .DESCRIPTION Lists all exported functions in the PwShSummit module with their aliases and synopses, rendered as a Spectre.Console table. Use -DataOnly for raw pipeline-friendly output. .PARAMETER DataOnly Write raw, unformatted data to the pipeline instead of a Spectre table. .EXAMPLE Get-PwShSummitModule .EXAMPLE Get-PwShSummitModule -DataOnly .LINK https://github.com/jorgeasaurus/PwShSummitSched #> [CmdletBinding()] [OutputType('String')] [Alias('summitmod')] param( [Parameter(HelpMessage = 'Write raw, unformatted data to the pipeline.')] [Alias('Raw')] [switch]$DataOnly ) $mod = Get-Module -Name PwShSummit $modVer = $mod.Version $cmds = $mod.ExportedFunctions.Keys | Get-Command if ($DataOnly) { $cmds | Select-Object -Property Name, @{Name = 'Alias'; Expression = { (Get-Alias -Definition $_.Name -ErrorAction SilentlyContinue).Name -join ',' } }, @{Name = 'Synopsis'; Expression = { (Get-Help $_.Name).Synopsis } } } else { $years = if ($script:AvailableYears.Count -gt 0) { $script:AvailableYears -join ', ' } else { 'none' } $title = "`n[link=https://github.com/jorgeasaurus/PwShSummitSched]PwShSummit [[v$modVer]][/] - Schedule data: $years" $cmds | Select-Object -Property @{ Name = 'Command' Expression = { $uri = (Get-Help $_.Name).relatedLinks.navigationLink.uri | Select-Object -First 1 if ($uri) { "[link=$uri]$($_.Name)[/]" } else { $_.Name } } }, @{ Name = 'Alias' Expression = { $a = (Get-Alias -Definition $_.Name -ErrorAction SilentlyContinue).Name -join ', ' if ($a) { "[Gold1 italic]$a[/]" } else { '' } } }, @{ Name = 'Synopsis' Expression = { (Get-Help $_.Name).Synopsis } } | Format-SpectreTable -Title $title -Color Cyan1 -HeaderColor SpringGreen2 -AllowMarkup -Wrap | Out-SpectreHost } } |