CmdID

CmdID / PowerShell / Cmdlets / Export

Export-ModuleMember

Specifies the module members that are exported. PowerShell reference

From the PowerShell reference 4 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

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 *Identify

Export specific aliases and functions

Export-ModuleMember -Function Get-Test, New-Test, Start-Test -Alias gtt, ntt, sttIdentify

Export no members

Export-ModuleMemberIdentify

Export a specific variable

Export-ModuleMember -Variable incrementIdentify

Multiple 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 sttIdentify

Export members in a dynamic module

New-Module -Script {function SayHello {"Hello!"}; Set-Alias Hi SayHello; Export-ModuleMember -Alias Hi -Function SayHello}Identify

Its page in the reference: Export-ModuleMember.

Parameters

4 in the PowerShell reference
-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.