CmdID / PowerShell / Cmdlets / Export
Export-ModuleMember
Specifies the module members that are exported. PowerShell reference
From the PowerShell reference 4 parameters
What it does
Specifies the module members that are exported. The Export-ModuleMember cmdlet specifies the module members that are exported from a script module (.psm1) file, or from a dynamic module created by using the New-Module cmdlet. Module members include cmdlets, functions, variables, and aliases. This cmdlet can be used only in a script module file or a dynamic module. If a script module does not include an Export-ModuleMember command, the functions and aliases in the script module are exported, but the variables are not. When a script module includes Export-ModuleMember commands, only the members specified in the Export-ModuleMember commands are exported. You can also use Export-ModuleMember to suppress or export members that the script module imports from other modules. An Export-ModuleMember command is optional, but it is a best practice. Even if the command confirms the default values, it demonstrates the intention of the module author.
Export-ModuleMember [[-Function] <String[]>] [-Cmdlet <String[]>] [-Variable <String[]>] [-Alias <String[]>] [<CommonParameters>]
Export functions and aliases in a script module
Export-ModuleMember -Function * -Alias *IdentifyExport specific aliases and functions
Export-ModuleMember -Function Get-Test, New-Test, Start-Test -Alias gtt, ntt, sttIdentifyExport no members
Export-ModuleMemberIdentifyExport a specific variable
Export-ModuleMember -Variable incrementIdentifyMultiple export commands
# From TestModule.psm1
function New-Test
{
Write-Output 'I am New-Test function'
}
Export-ModuleMember -Function New-Test
function Validate-Test
{
Write-Output 'I am Validate-Test function'
}
function Start-Test
{
Write-Output 'I am Start-Test function'
}
Set-Alias stt Start-Test
Export-ModuleMember -Function Start-Test -Alias sttIdentifyExport members in a dynamic module
New-Module -Script {function SayHello {"Hello!"}; Set-Alias Hi SayHello; Export-ModuleMember -Alias Hi -Function SayHello}IdentifyIts page in the reference: Export-ModuleMember.
Parameters
-AliasSpecifies the aliases that are exported from the script module file. Enter the alias names. Wildcard characters are permitted.-CmdletSpecifies the cmdlets that are exported from the script module file. Enter the cmdlet names. Wildcard characters are permitted.
You cannot create cmdlets in a script module file, but you can import cmdlets from a binary module into a script module and re-export them from the script module.-FunctionSpecifies the functions that are exported from the script module file. Enter the function names. Wildcard characters are permitted. You can also pipe function name strings to Export-ModuleMember.-VariableSpecifies the variables that are exported from the script module file. Enter the variable names, without a dollar sign character ($). Wildcard characters are permitted.