Updates from: 08/18/2021 03:09:22
Service Microsoft Docs article Related commit history on GitHub Change details
Microsoft.PowerShell.Core About Functions Advanced Parameters (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md
New-PSDrive -Name 'User' -PSProvider FileSystem -Root $env:HOMEPATH
Name Used (GB) Free (GB) Provider Root ---- --------- --------- -------- ---- User 75.76 24.24 FileSystem C:\Users\ExampleUser
+```
```powershell Test-UserDrivePath -Path 'User:\A_folder_that_does_not_exist'
Microsoft.PowerShell.Core Export Modulemember (5.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/5.1/Microsoft.PowerShell.Core/Export-ModuleMember.md
external help file: System.Management.Automation.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 08/17/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/export-modulemember?view=powershell-5.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Export-ModuleMember --- # Export-ModuleMember
-## SYNOPSIS
+## Synopsis
Specifies the module members that are exported.
-## SYNTAX
+## Syntax
``` Export-ModuleMember [[-Function] <String[]>] [-Cmdlet <String[]>] [-Variable <String[]>] [-Alias <String[]>] [<CommonParameters>] ```
-## DESCRIPTION
+## Description
-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.
+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.
+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.
+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.
-## EXAMPLES
+## Examples
### Example 1: Export functions and aliases in a script module
Export-ModuleMember
This command specifies that no members defined in the script module are exported. This command prevents the module members from being exported, but it does not hide the members.
-Users can read and copy module members or use the call operator (&) to invoke module members that are not exported.
+Users can read and copy module members or use the call operator (`&`) to invoke module members that
+are not exported.
### Example 4: Export a specific variable
Users can read and copy module members or use the call operator (&) to invoke mo
Export-ModuleMember -Variable increment ```
-This command exports only the $increment variable from the script module.
+This command exports only the `$increment` variable from the script module.
No other members are exported.
-If you want to export a variable, in addition to exporting the functions in a module, the **Export-ModuleMember** command must include the names of all of the functions and the name of the variable.
+If you want to export a variable, in addition to exporting the functions in a module, the
+`Export-ModuleMember` command must include the names of all of the functions and the name of the
+variable.
### Example 5: Multiple export commands ```powershell # From TestModule.psm1
-Function New-Test
+function New-Test
{ Write-Output 'I am New-Test function' }
Set-Alias stt Start-Test
Export-ModuleMember -Function Start-Test -Alias stt ```
-These commands show how multiple **Export-ModuleMember** commands are interpreted in a script module (.psm1) file.
+These commands show how multiple `Export-ModuleMember` commands are interpreted in a script module
+(`.psm1`) file.
-These commands create three functions and one alias, and then they export two of the functions and the alias.
+These commands create three functions and one alias, and then they export two of the functions and
+the alias.
-Without the **Export-ModuleMember** commands, all three of the functions and the alias would be exported.
-With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Test** functions and the STT alias are exported.
+Without the `Export-ModuleMember` commands, all three of the functions and the alias would be
+exported. With the `Export-ModuleMember` commands, only the `New-Test` and `Start-Test` functions
+and the `STT` alias are exported.
### Example 6: Export members in a dynamic module
With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Tes
New-Module -Script {function SayHello {"Hello!"}; Set-Alias Hi SayHello; Export-ModuleMember -Alias Hi -Function SayHello} ```
-This command shows how to use Export-ModuleMember in a dynamic module that is created by using the **New-Module** cmdlet.
+This command shows how to use `Export-ModuleMember` in a dynamic module that is created by using the
+`New-Module` cmdlet.
-In this example, **Export-ModuleMember** is used to export both the Hi alias and the **SayHello** function in the dynamic module.
+In this example, `Export-ModuleMember` is used to export both the `Hi` alias and the `SayHello`
+function in the dynamic module.
-### Example 7: Declare and export a function in a single command
-
-```powershell
-# From TestModule.psm1
-function Export
-{
- param (
- [Parameter(Mandatory=$true)]
- [ValidateSet("function","variable")]
- $Type,
- [Parameter(Mandatory=$true)]
- $Name,
- [Parameter(Mandatory=$true)]
- $Value
- )
-
- if ($Type -eq "function")
- {
- Set-item "function:script:$Name" $Value
- Export-ModuleMember $Name
- }
- else
- {
- Set-Variable -scope Script $Name $Value
- Export-ModuleMember -variable $Name
- }
-}
-
-Export function New-Test {Write-Output 'I am New-Test function'}
-function helper {Write-Output 'I am helper function'}
-
-Export variable Interval 0
-$Interval = 2
-```
-
-This example includes a function named **Export** that declares a function or creates a variable, and then writes an `Export-ModuleMember` command for the function or variable.
-This lets you declare and export a function or variable in a single command.
-
-To use the **Export** function, include it in your script module.
-To export a function, type `Export` before the **Function** keyword.
-
-To export a variable, use the following format to declare the variable and set its value:
-
-`Export variable <variable-name> <value>`
-
-The commands in the example show the correct format.
-In this example, only the **New-Test** function and the $Interval variable are exported.
-
-## PARAMETERS
+## Parameters
### -Alias
-Specifies the aliases that are exported from the script module file.
-Enter the alias names.
-Wildcard characters are permitted.
+Specifies the aliases that are exported from the script module file. Enter the alias names. Wildcard
+characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Cmdlet
-Specifies the cmdlets that are exported from the script module file.
-Enter the cmdlet names.
+Specifies 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.
+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.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Function
-Specifies 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**.
+Specifies 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`.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Variable
-Specifies the variables that are exported from the script module file.
-Enter the variable names, without a dollar sign.
-Wildcard characters are permitted.
+Specifies the variables that are exported from the script module file. Enter the variable names,
+without a dollar sign character (`$`). Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.String You can pipe function name strings to this cmdlet.
-## OUTPUTS
+## Outputs
### None This cmdlet does not generate any output.
-## NOTES
+## Notes
-* To exclude a member from the list of exported members, add an **Export-ModuleMember** command that lists all other members but omits the member that you want to exclude.
+- To exclude a member from the list of exported members, add an `Export-ModuleMember` command that
+ lists all other members but omits the member that you want to exclude.
-## RELATED LINKS
+## Related links
[Get-Module](Get-Module.md)
Microsoft.PowerShell.Core About Functions Advanced Parameters (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md
New-PSDrive -Name 'User' -PSProvider FileSystem -Root $env:HOMEPATH
Name Used (GB) Free (GB) Provider Root ---- --------- --------- -------- ---- User 75.76 24.24 FileSystem C:\Users\ExampleUser
+```
```powershell Test-UserDrivePath -Path 'User:\A_folder_that_does_not_exist'
Microsoft.PowerShell.Core Export Modulemember (7.0) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.0/Microsoft.PowerShell.Core/Export-ModuleMember.md
external help file: System.Management.Automation.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 08/17/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/export-modulemember?view=powershell-7&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Export-ModuleMember --- # Export-ModuleMember
-## SYNOPSIS
+## Synopsis
Specifies the module members that are exported.
-## SYNTAX
+## Syntax
``` Export-ModuleMember [[-Function] <String[]>] [-Cmdlet <String[]>] [-Variable <String[]>] [-Alias <String[]>] [<CommonParameters>] ```
-## DESCRIPTION
+## Description
-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.
+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.
+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.
+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.
-## EXAMPLES
+## Examples
### Example 1: Export functions and aliases in a script module
Export-ModuleMember
This command specifies that no members defined in the script module are exported. This command prevents the module members from being exported, but it does not hide the members.
-Users can read and copy module members or use the call operator (&) to invoke module members that are not exported.
+Users can read and copy module members or use the call operator (`&`) to invoke module members that
+are not exported.
### Example 4: Export a specific variable
Users can read and copy module members or use the call operator (&) to invoke mo
Export-ModuleMember -Variable increment ```
-This command exports only the $increment variable from the script module.
+This command exports only the `$increment` variable from the script module.
No other members are exported.
-If you want to export a variable, in addition to exporting the functions in a module, the **Export-ModuleMember** command must include the names of all of the functions and the name of the variable.
+If you want to export a variable, in addition to exporting the functions in a module, the
+`Export-ModuleMember` command must include the names of all of the functions and the name of the
+variable.
### Example 5: Multiple export commands
Set-Alias stt Start-Test
Export-ModuleMember -Function Start-Test -Alias stt ```
-These commands show how multiple **Export-ModuleMember** commands are interpreted in a script module (.psm1) file.
+These commands show how multiple `Export-ModuleMember` commands are interpreted in a script module
+(`.psm1`) file.
-These commands create three functions and one alias, and then they export two of the functions and the alias.
+These commands create three functions and one alias, and then they export two of the functions and
+the alias.
-Without the **Export-ModuleMember** commands, all three of the functions and the alias would be exported.
-With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Test** functions and the STT alias are exported.
+Without the `Export-ModuleMember` commands, all three of the functions and the alias would be
+exported. With the `Export-ModuleMember` commands, only the `New-Test` and `Start-Test` functions
+and the `STT` alias are exported.
### Example 6: Export members in a dynamic module
With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Tes
New-Module -Script {function SayHello {"Hello!"}; Set-Alias Hi SayHello; Export-ModuleMember -Alias Hi -Function SayHello} ```
-This command shows how to use Export-ModuleMember in a dynamic module that is created by using the **New-Module** cmdlet.
+This command shows how to use `Export-ModuleMember` in a dynamic module that is created by using the
+`New-Module` cmdlet.
-In this example, **Export-ModuleMember** is used to export both the Hi alias and the **SayHello** function in the dynamic module.
+In this example, `Export-ModuleMember` is used to export both the `Hi` alias and the `SayHello`
+function in the dynamic module.
-### Example 7: Declare and export a function in a single command
-
-```powershell
-# From TestModule.psm1
-function Export
-{
- param (
- [Parameter(Mandatory=$true)]
- [ValidateSet("function","variable")]
- $Type,
- [Parameter(Mandatory=$true)]
- $Name,
- [Parameter(Mandatory=$true)]
- $Value
- )
-
- if ($Type -eq "function")
- {
- Set-item "function:script:$Name" $Value
- Export-ModuleMember $Name
- }
- else
- {
- Set-Variable -scope Script $Name $Value
- Export-ModuleMember -variable $Name
- }
-}
-
-Export function New-Test {Write-Output 'I am New-Test function'}
-function helper {Write-Output 'I am helper function'}
-
-Export variable Interval 0
-$Interval = 2
-```
-
-This example includes a function named **Export** that declares a function or creates a variable, and then writes an `Export-ModuleMember` command for the function or variable.
-This lets you declare and export a function or variable in a single command.
-
-To use the **Export** function, include it in your script module.
-To export a function, type `Export` before the **Function** keyword.
-
-To export a variable, use the following format to declare the variable and set its value:
-
-`Export variable <variable-name> <value>`
-
-The commands in the example show the correct format.
-In this example, only the **New-Test** function and the $Interval variable are exported.
-
-## PARAMETERS
+## Parameters
### -Alias
-Specifies the aliases that are exported from the script module file.
-Enter the alias names.
-Wildcard characters are permitted.
+Specifies the aliases that are exported from the script module file. Enter the alias names. Wildcard
+characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Cmdlet
-Specifies the cmdlets that are exported from the script module file.
-Enter the cmdlet names.
+Specifies 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.
+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.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Function
-Specifies 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**.
+Specifies 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`.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Variable
-Specifies the variables that are exported from the script module file.
-Enter the variable names, without a dollar sign.
-Wildcard characters are permitted.
+Specifies the variables that are exported from the script module file. Enter the variable names,
+without a dollar sign character (`$`). Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.String You can pipe function name strings to this cmdlet.
-## OUTPUTS
+## Outputs
### None This cmdlet does not generate any output.
-## NOTES
+## Notes
-* To exclude a member from the list of exported members, add an **Export-ModuleMember** command that lists all other members but omits the member that you want to exclude.
+- To exclude a member from the list of exported members, add an `Export-ModuleMember` command that
+ lists all other members but omits the member that you want to exclude.
-## RELATED LINKS
+## Related links
[Get-Module](Get-Module.md) [Import-Module](Import-Module.md) [Remove-Module](Remove-Module.md)+
+[about_Modules](About/about_Modules.md)
Microsoft.PowerShell.Core About Functions Advanced Parameters (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md
New-PSDrive -Name 'User' -PSProvider FileSystem -Root $env:HOMEPATH
Name Used (GB) Free (GB) Provider Root ---- --------- --------- -------- ---- User 75.76 24.24 FileSystem C:\Users\ExampleUser
+```
```powershell Test-UserDrivePath -Path 'User:\A_folder_that_does_not_exist'
Microsoft.PowerShell.Core Export Modulemember (7.1) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.1/Microsoft.PowerShell.Core/Export-ModuleMember.md
external help file: System.Management.Automation.dll-Help.xml
keywords: powershell,cmdlet Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 08/17/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/export-modulemember?view=powershell-7.1&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Export-ModuleMember --- # Export-ModuleMember
-## SYNOPSIS
+## Synopsis
Specifies the module members that are exported.
-## SYNTAX
+## Syntax
``` Export-ModuleMember [[-Function] <String[]>] [-Cmdlet <String[]>] [-Variable <String[]>] [-Alias <String[]>] [<CommonParameters>] ```
-## DESCRIPTION
+## Description
-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.
+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.
+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.
+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.
-## EXAMPLES
+## Examples
### Example 1: Export functions and aliases in a script module
Export-ModuleMember
This command specifies that no members defined in the script module are exported. This command prevents the module members from being exported, but it does not hide the members.
-Users can read and copy module members or use the call operator (&) to invoke module members that are not exported.
+Users can read and copy module members or use the call operator (`&`) to invoke module members that
+are not exported.
### Example 4: Export a specific variable
Users can read and copy module members or use the call operator (&) to invoke mo
Export-ModuleMember -Variable increment ```
-This command exports only the $increment variable from the script module.
+This command exports only the `$increment` variable from the script module.
No other members are exported.
-If you want to export a variable, in addition to exporting the functions in a module, the **Export-ModuleMember** command must include the names of all of the functions and the name of the variable.
+If you want to export a variable, in addition to exporting the functions in a module, the
+`Export-ModuleMember` command must include the names of all of the functions and the name of the
+variable.
### Example 5: Multiple export commands ```powershell # From TestModule.psm1
-Function New-Test
+function New-Test
{ Write-Output 'I am New-Test function' }
Set-Alias stt Start-Test
Export-ModuleMember -Function Start-Test -Alias stt ```
-These commands show how multiple **Export-ModuleMember** commands are interpreted in a script module (.psm1) file.
+These commands show how multiple `Export-ModuleMember` commands are interpreted in a script module
+(`.psm1`) file.
-These commands create three functions and one alias, and then they export two of the functions and the alias.
+These commands create three functions and one alias, and then they export two of the functions and
+the alias.
-Without the **Export-ModuleMember** commands, all three of the functions and the alias would be exported.
-With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Test** functions and the STT alias are exported.
+Without the `Export-ModuleMember` commands, all three of the functions and the alias would be
+exported. With the `Export-ModuleMember` commands, only the `New-Test` and `Start-Test` functions
+and the `STT` alias are exported.
### Example 6: Export members in a dynamic module
With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Tes
New-Module -Script {function SayHello {"Hello!"}; Set-Alias Hi SayHello; Export-ModuleMember -Alias Hi -Function SayHello} ```
-This command shows how to use Export-ModuleMember in a dynamic module that is created by using the **New-Module** cmdlet.
+This command shows how to use `Export-ModuleMember` in a dynamic module that is created by using the
+`New-Module` cmdlet.
-In this example, **Export-ModuleMember** is used to export both the Hi alias and the **SayHello** function in the dynamic module.
+In this example, `Export-ModuleMember` is used to export both the `Hi` alias and the `SayHello`
+function in the dynamic module.
-### Example 7: Declare and export a function in a single command
-
-```powershell
-# From TestModule.psm1
-function Export
-{
- param (
- [Parameter(Mandatory=$true)]
- [ValidateSet("function","variable")]
- $Type,
- [Parameter(Mandatory=$true)]
- $Name,
- [Parameter(Mandatory=$true)]
- $Value
- )
-
- if ($Type -eq "function")
- {
- Set-item "function:script:$Name" $Value
- Export-ModuleMember $Name
- }
- else
- {
- Set-Variable -scope Script $Name $Value
- Export-ModuleMember -variable $Name
- }
-}
-
-Export function New-Test {Write-Output 'I am New-Test function'}
-function helper {Write-Output 'I am helper function'}
-
-Export variable Interval 0
-$Interval = 2
-```
-
-This example includes a function named **Export** that declares a function or creates a variable, and then writes an `Export-ModuleMember` command for the function or variable.
-This lets you declare and export a function or variable in a single command.
-
-To use the **Export** function, include it in your script module.
-To export a function, type `Export` before the **Function** keyword.
-
-To export a variable, use the following format to declare the variable and set its value:
-
-`Export variable <variable-name> <value>`
-
-The commands in the example show the correct format.
-In this example, only the **New-Test** function and the $Interval variable are exported.
-
-## PARAMETERS
+## Parameters
### -Alias
-Specifies the aliases that are exported from the script module file.
-Enter the alias names.
-Wildcard characters are permitted.
+Specifies the aliases that are exported from the script module file. Enter the alias names. Wildcard
+characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Cmdlet
-Specifies the cmdlets that are exported from the script module file.
-Enter the cmdlet names.
+Specifies 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.
+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.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Function
-Specifies 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**.
+Specifies 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`.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Variable
-Specifies the variables that are exported from the script module file.
-Enter the variable names, without a dollar sign.
-Wildcard characters are permitted.
+Specifies the variables that are exported from the script module file. Enter the variable names,
+without a dollar sign character (`$`). Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.String You can pipe function name strings to this cmdlet.
-## OUTPUTS
+## Outputs
### None This cmdlet does not generate any output.
-## NOTES
+## Notes
-* To exclude a member from the list of exported members, add an **Export-ModuleMember** command that lists all other members but omits the member that you want to exclude.
+- To exclude a member from the list of exported members, add an `Export-ModuleMember` command that
+ lists all other members but omits the member that you want to exclude.
-## RELATED LINKS
+## Related links
[Get-Module](Get-Module.md)
This cmdlet does not generate any output.
[Remove-Module](Remove-Module.md)
+[about_Modules](About/about_Modules.md)
Microsoft.PowerShell.Core About ANSI Terminals (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_ANSI_Terminals.md
The following members control how or when ANSI formatting is used:
- `$PSStyle.OutputRendering` is a `System.Management.Automation.OutputRendering` enum with the values:
- - **Automatic**: This is the default. If the host supports VirtualTerminal,
- then ANSI is always passed as-is, otherwise plaintext
+ - **Automatic**: If the host supports VirtualTerminal, then ANSI is always
+ passed as-is, otherwise plaintext
- **ANSI**: ANSI is always passed through as-is - **PlainText**: ANSI escape sequences are always stripped so that it is only plain text
- - **Host**: This would be the macOS behavior where the ANSI escape
- sequences are removed in redirected or piped output.
+ - **Host**: This is the default behavior. The ANSI escape sequences are
+ removed in redirected or piped output.
- The `$PSStyle.Background` and `$PSStyle.Foreground` members are strings that contain the ANSI escape sequences for the 16 standard console colors.
Microsoft.PowerShell.Core About Automatic Variables (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Automatic_Variables.md
The following members control how or when ANSI formatting is used:
- `$PSStyle.OutputRendering` is a `System.Management.Automation.OutputRendering` enum with the values:
- - **Automatic**: This is the default. If the host supports VirtualTerminal,
- then ANSI is always passed as-is, otherwise plaintext
+ - **Automatic**: If the host supports VirtualTerminal, then ANSI is always
+ passed as-is, otherwise plaintext
- **ANSI**: ANSI is always passed through as-is - **PlainText**: ANSI escape sequences are always stripped so that it is only plain text
- - **HostOnly**: This would be the macOS behavior where the ANSI escape
- sequences are removed in redirected or piped output.
+ - **Host**: This is the default behavior. The ANSI escape sequences are
+ removed in redirected or piped output.
- The `$PSStyle.Background` and `$PSStyle.Foreground` members are strings that contain the ANSI escape sequences for the 16 standard console colors.
Microsoft.PowerShell.Core About Functions Advanced Parameters (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/About/about_Functions_Advanced_Parameters.md
New-PSDrive -Name 'User' -PSProvider FileSystem -Root $env:HOMEPATH
Name Used (GB) Free (GB) Provider Root ---- --------- --------- -------- ---- User 75.76 24.24 FileSystem C:\Users\ExampleUser
+```
```powershell Test-UserDrivePath -Path 'User:\A_folder_that_does_not_exist'
Microsoft.PowerShell.Core Export Modulemember (7.2) https://github.com/MicrosoftDocs/PowerShell-Docs/commits/staging/reference/7.2/Microsoft.PowerShell.Core/Export-ModuleMember.md
external help file: System.Management.Automation.dll-Help.xml Locale: en-US Module Name: Microsoft.PowerShell.Core Previously updated : 06/09/2017 Last updated : 08/17/2021 online version: https://docs.microsoft.com/powershell/module/microsoft.powershell.core/export-modulemember?view=powershell-7.2&WT.mc_id=ps-gethelp schema: 2.0.0 Title: Export-ModuleMember --- # Export-ModuleMember
-## SYNOPSIS
+## Synopsis
Specifies the module members that are exported.
-## SYNTAX
+## Syntax
``` Export-ModuleMember [[-Function] <String[]>] [-Cmdlet <String[]>] [-Variable <String[]>] [-Alias <String[]>] [<CommonParameters>] ```
-## DESCRIPTION
+## Description
-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.
+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.
+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.
+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.
-## EXAMPLES
+## Examples
### Example 1: Export functions and aliases in a script module
Export-ModuleMember
This command specifies that no members defined in the script module are exported. This command prevents the module members from being exported, but it does not hide the members.
-Users can read and copy module members or use the call operator (&) to invoke module members that are not exported.
+Users can read and copy module members or use the call operator (`&`) to invoke module members that
+are not exported.
### Example 4: Export a specific variable
Users can read and copy module members or use the call operator (&) to invoke mo
Export-ModuleMember -Variable increment ```
-This command exports only the $increment variable from the script module.
+This command exports only the `$increment` variable from the script module.
No other members are exported.
-If you want to export a variable, in addition to exporting the functions in a module, the **Export-ModuleMember** command must include the names of all of the functions and the name of the variable.
+If you want to export a variable, in addition to exporting the functions in a module, the
+`Export-ModuleMember` command must include the names of all of the functions and the name of the
+variable.
### Example 5: Multiple export commands ```powershell # From TestModule.psm1
-Function New-Test
+function New-Test
{ Write-Output 'I am New-Test function' }
Set-Alias stt Start-Test
Export-ModuleMember -Function Start-Test -Alias stt ```
-These commands show how multiple **Export-ModuleMember** commands are interpreted in a script module (.psm1) file.
+These commands show how multiple `Export-ModuleMember` commands are interpreted in a script module
+(`.psm1`) file.
-These commands create three functions and one alias, and then they export two of the functions and the alias.
+These commands create three functions and one alias, and then they export two of the functions and
+the alias.
-Without the **Export-ModuleMember** commands, all three of the functions and the alias would be exported.
-With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Test** functions and the STT alias are exported.
+Without the `Export-ModuleMember` commands, all three of the functions and the alias would be
+exported. With the `Export-ModuleMember` commands, only the `New-Test` and `Start-Test` functions
+and the `STT` alias are exported.
### Example 6: Export members in a dynamic module
With the **Export-ModuleMember** commands, only the **New-Test** and **Start-Tes
New-Module -Script {function SayHello {"Hello!"}; Set-Alias Hi SayHello; Export-ModuleMember -Alias Hi -Function SayHello} ```
-This command shows how to use Export-ModuleMember in a dynamic module that is created by using the **New-Module** cmdlet.
+This command shows how to use `Export-ModuleMember` in a dynamic module that is created by using the
+`New-Module` cmdlet.
-In this example, **Export-ModuleMember** is used to export both the Hi alias and the **SayHello** function in the dynamic module.
+In this example, `Export-ModuleMember` is used to export both the `Hi` alias and the `SayHello`
+function in the dynamic module.
-### Example 7: Declare and export a function in a single command
-
-```powershell
-# From TestModule.psm1
-function Export
-{
- param (
- [Parameter(Mandatory=$true)]
- [ValidateSet("function","variable")]
- $Type,
- [Parameter(Mandatory=$true)]
- $Name,
- [Parameter(Mandatory=$true)]
- $Value
- )
-
- if ($Type -eq "function")
- {
- Set-item "function:script:$Name" $Value
- Export-ModuleMember $Name
- }
- else
- {
- Set-Variable -scope Script $Name $Value
- Export-ModuleMember -variable $Name
- }
-}
-
-Export function New-Test {Write-Output 'I am New-Test function'}
-function helper {Write-Output 'I am helper function'}
-
-Export variable Interval 0
-$Interval = 2
-```
-
-This example includes a function named **Export** that declares a function or creates a variable, and then writes an `Export-ModuleMember` command for the function or variable.
-This lets you declare and export a function or variable in a single command.
-
-To use the **Export** function, include it in your script module.
-To export a function, type `Export` before the **Function** keyword.
-
-To export a variable, use the following format to declare the variable and set its value:
-
-`Export variable <variable-name> <value>`
-
-The commands in the example show the correct format.
-In this example, only the **New-Test** function and the $Interval variable are exported.
-
-## PARAMETERS
+## Parameters
### -Alias
-Specifies the aliases that are exported from the script module file.
-Enter the alias names.
-Wildcard characters are permitted.
+Specifies the aliases that are exported from the script module file. Enter the alias names. Wildcard
+characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Cmdlet
-Specifies the cmdlets that are exported from the script module file.
-Enter the cmdlet names.
+Specifies 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.
+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.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Function
-Specifies 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**.
+Specifies 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`.
```yaml Type: System.String[]
Accept wildcard characters: True
### -Variable
-Specifies the variables that are exported from the script module file.
-Enter the variable names, without a dollar sign.
-Wildcard characters are permitted.
+Specifies the variables that are exported from the script module file. Enter the variable names,
+without a dollar sign character (`$`). Wildcard characters are permitted.
```yaml Type: System.String[]
Accept wildcard characters: True
### CommonParameters
-This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
+This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
+-InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose,
+-WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).
-## INPUTS
+## Inputs
### System.String You can pipe function name strings to this cmdlet.
-## OUTPUTS
+## Outputs
### None This cmdlet does not generate any output.
-## NOTES
+## Notes
-* To exclude a member from the list of exported members, add an **Export-ModuleMember** command that lists all other members but omits the member that you want to exclude.
+- To exclude a member from the list of exported members, add an `Export-ModuleMember` command that
+ lists all other members but omits the member that you want to exclude.
-## RELATED LINKS
+## Related links
[Get-Module](Get-Module.md)
This cmdlet does not generate any output.
[Remove-Module](Remove-Module.md)
+[about_Modules](About/about_Modules.md)