Problem with "get-help select-string"
See original GitHub issuePrerequisites
- Write a descriptive title.
- Make sure you are able to repro it on the latest released version
- Search the existing issues.
- Refer to the FAQ.
- Refer to Differences between Windows PowerShell 5.1 and PowerShell.
Steps to reproduce
In Powershell Core 7.2.6 on Windows 11, type “get-help select-string” command and press enter.
Expected behavior
The help of the command select-string
Actual behavior
It doesn't show me the help but a bunch of characters, which I think mean languages and countries.
Error details
No response
Environment data
Name Value
---- -----
PSVersion 7.2.6
PSEdition Core
GitCommitId 7.2.6
OS Microsoft Windows 10.0.22000
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals

Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Select-String (Microsoft.PowerShell.Utility)
The Select-String cmdlet uses regular expression matching to search for text patterns in input strings and files. You can use Select-String similar to...
Read more >Select-String doesn't do what you think it does : r/PowerShell
Get-Help Select-String -Parameter SimpleMatch. Indicates that the cmdlet uses a simple match rather than a regular expression match.
Read more >How to Access Powershell Select-String Return Values
NET data type(s) of the objects output by that cmdlet. To see this section locally, you must invoke Get-Help with the -Full switch,...
Read more >Select-String. How to use multiple pattern conditions?
Hello,. I am trying to parse through a log file searching for lines that contain strings. The below scripts works to pull all...
Read more >Powershell: Search for String or grep ...
The Select-String cmdlet searches for text and text patterns in input strings and files. You can use Select-String similar to grep in UNIX...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You are getting the correct text when the help file for
Select-stringis absent.What happens with no help file, is
Get-Helplooks at the command’s parameter-sets and for each one it builds a block under “syntax”. Then for each parameter it looks to see what type it is, and if it has prescribed values in a validateSet or an enum. The screen shot shows it works through-Patternand-Pathbefore it gets to-culture, and it will have-SimpleMatch-CaseSensitiveetc after that. As @MartinGC94 says there is a LOT in the validate set for-culture, andGet-Helpinserts the equivalent ofAnd repeats it for each of the six parameter sets which have a -culture parameter. So we get a lot, six times over.
The default help text should end
So the primary fix is to install help. But in in some situations that’s not an option (e.g. PowerShell installed from a private repo on a server without internet access). As @dkaszews says stopping the list after a certain number of items might be smarter. They can be stopped at source by putting something into https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/help/DefaultCommandHelpObjectBuilder.cs (see from line 251 to 348 ) that limits the number of values from an enum or validate set. But if someone creates a help file with a stupid number of parameter values in a parameter value group, they will still be displayed. Maybe we want to honour what is in file on all occasions, but if not the change can be made at output time. I’m not sure where it stored in pwsh, but the formatting for Windows PowerShell is defined by C:\Windows\System32\WindowsPowerShell\v1.0\Help.format.ps1xml - in that file its line 212 which builds the output with
It would be fairly easy (I think) to make that
$_.ParameterValueGroup.ParameterValue[0..20]and get only the first 20 values.If people think either option is worthwhile, a new issue can be opened asking for that. (Upvote this comment enough and I’ll do it!)
@jhoneill I don’t see a benefit in skipping the
ifstatement, as depending on how efficient PowerShell implementation of regex is, you may waste a lot of time running complicated replacements just to do nothing.