Public/Get-ExportedFunction.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
function Get-ExportedFunction {
  <#
  .SYNOPSIS
    Output the functions made available by this module.
  .DESCRIPTION
    The output from this function is used when loading the PowerShell profile,
    and for making ad-hoc checking of the helper functions in the profile more
    accessible.
  .EXAMPLE
    Get-ExportedFunction
  #>


  $MODULE = 'TsekProfile'

  $functions = (Get-Module -Name $MODULE).ExportedCommands.Values.Name

  if (-not $functions) {
    throw "Failed to determine exported functions for: $MODULE"
  }

  $function_string = $functions -join ', '

  Write-Host "$MODULE exported functions: " -NoNewline
  Write-Host $function_string -ForegroundColor Green
}