Prerequisites
Steps to reproduce
I am writing a PowerShell module and adding help text for each of my exported cmdlets.
Several of my commands include multi-line examples, showing the command usage and example output, e.g.:
.EXAMPLE
PS> $devices = Get-MTPDeviceList
PS> if ($devices) { $devices[0].Name }
"My Phone"
.EXAMPLE
# Some explanatory text about the example.
PS> Get-MTPDeviceList
Name Type
---- ----
Some Phone Mobile Phone
I have tested my module in both Visual Studio Code's PowerShell terminal and also a separate instance of PowerShell in Terminal. When calling Get-Help Get-MTPDeviceList with switches that show example text (e.g. -Full or -Examples), the formatting of the displayed examples text is incorrect.
Specifically:
- Any leading spaces between the "PS>" and the rest of the string on the first line is removed.
- If the first line of an example is a comment (with or without a leading
#), the text "PS >" is inserted before it.
Expected behavior
The following output should be displayed in the examples section when Get-Help -Full is called:
-------------------------- EXAMPLE 1 --------------------------
PS> $devices = Get-MTPDeviceList
PS> if ($devices) { $devices[0].Name }
"My Phone"
-------------------------- EXAMPLE 2 --------------------------
# Some explanatory text about the example.
PS> Get-MTPDeviceList
Name Type
---- ----
Some Phone Mobile Phone
Actual behavior
The following is output. Note the removal of the space character in the first line of the first example and the insertion of the text "PS >" in the first line of the second example.
-------------------------- EXAMPLE 1 --------------------------
PS>$devices = Get-MTPDeviceList
PS> if ($devices) { $devices[0].Name }
"My Phone"
-------------------------- EXAMPLE 2 --------------------------
PS > # Some explanatory text about the example.
PS> Get-MTPDeviceList
Name Type
---- ----
Some Phone Mobile Phone
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.4.2
PSEdition Core
GitCommitId 7.4.2
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
I am writing a PowerShell module and adding help text for each of my exported cmdlets.
Several of my commands include multi-line examples, showing the command usage and example output, e.g.:
I have tested my module in both Visual Studio Code's PowerShell terminal and also a separate instance of PowerShell in Terminal. When calling
Get-Help Get-MTPDeviceListwith switches that show example text (e.g.-Fullor-Examples), the formatting of the displayed examples text is incorrect.Specifically:
#), the text "PS >" is inserted before it.Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response