PowerShell / PowerShell/platyPS
Import-MarkdownCommandHelp does not resolve paths correctly in Windows PowerShell
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 871
- Forks
- 166
- Avg merge
- 21h 17m
- Merged PRs (30d)
- 1
Description
Prerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest version
- Search the existing issues.
Steps to reproduce
In Windows PowerShell if I try to import markdown files from the pipeline I experience this:
PS C:\Windows\system32> ls 'C:\Users\Martin\source\repos\MouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
Import-MarkdownCommandHelp : Cannot find path 'C:\Windows\system32\Get-MouseSettings.md' because it does not exist.
At line:1 char:78
+ ... ouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.String[]:String[]) [Import-MarkdownCommandHelp], ItemNotFoundException
+ FullyQualifiedErrorId : Could not resolve Path,Microsoft.PowerShell.PlatyPS.ImportMarkdownHelpCommand
Import-MarkdownCommandHelp : Cannot find path 'C:\Windows\system32\Set-MouseSettings.md' because it does not exist.
At line:1 char:78
+ ... ouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.String[]:String[]) [Import-MarkdownCommandHelp], ItemNotFoundException
+ FullyQualifiedErrorId : Could not resolve Path,Microsoft.PowerShell.PlatyPS.ImportMarkdownHelpCommand
PS C:\Windows\system32>
Note how it tries to find the file names in the current directory. If I do the same from PowerShell 7 it works perfectly fine:
PS C:\Windows\System32> ls 'C:\Users\Martin\source\repos\MouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
Title ModuleName Synopsis
----- ---------- --------
Get-MouseSettings MouseSettings Gets all the current mouse settings that this module can manage.
Set-MouseSettings MouseSettings Sets various mouse settings.
PS C:\Windows\System32>
Expected behavior
It finds the files from pipeline input like so:
PS C:\Windows\System32> ls 'C:\Users\Martin\source\repos\MouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
Title ModuleName Synopsis
----- ---------- --------
Get-MouseSettings MouseSettings Gets all the current mouse settings that this module can manage.
Set-MouseSettings MouseSettings Sets various mouse settings.
Actual behavior
It throws an error because it's trying to find files in the wrong directory:
PS C:\Windows\system32> ls 'C:\Users\Martin\source\repos\MouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
Import-MarkdownCommandHelp : Cannot find path 'C:\Windows\system32\Get-MouseSettings.md' because it does not exist.
At line:1 char:78
+ ... ouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.String[]:String[]) [Import-MarkdownCommandHelp], ItemNotFoundException
+ FullyQualifiedErrorId : Could not resolve Path,Microsoft.PowerShell.PlatyPS.ImportMarkdownHelpCommand
Import-MarkdownCommandHelp : Cannot find path 'C:\Windows\system32\Set-MouseSettings.md' because it does not exist.
At line:1 char:78
+ ... ouseSettings\Docs' -Recurse -Filter *.md | Import-MarkdownCommandHelp
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.String[]:String[]) [Import-MarkdownCommandHelp], ItemNotFoundException
+ FullyQualifiedErrorId : Could not resolve Path,Microsoft.PowerShell.PlatyPS.ImportMarkdownHelpCommand
PS C:\Windows\system32>
Error details
Environment data
Name Value
---- -----
PSVersion 5.1.26100.7920
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.26100.7920
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
Version
1.0.1
Visuals
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Import-MarkdownCommandHelp entry point and reproduce the pipeline behavior in Windows PowerShell 5.1 and PowerShell 7 using the commands and paths shown. Trace how pipeline input is resolved and compare the resulting paths between versions. Done means the Windows PowerShell invocation resolves the supplied Markdown files instead of searching the current directory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, powershell
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100