Get-Help does not work for script files containing using statements.
See original GitHub issueSteps to reproduce
Create a script file test.ps1 with the following content:
using namespace System.Management.Automation
<#
.SYNOPSIS
A simple script for problem reproduction.
#>
Param ($SampleParam)
Execute following command:
> Get-Help .\test.ps1
Expected behavior
Get-Help .\test.ps1
NAME
...\test.ps1
SYNOPSIS
A simple script for problem reproduction.
SYNTAX
...\test.ps1 [[-SampleParam] <Object>] [<CommonParameters>]
DESCRIPTION
RELATED LINKS
REMARKS
To see the examples, type: "Get-Help ...\test.ps1 -Examples"
For more information, type: "Get-Help ...\test.ps1 -Detailed"
For technical information, type: "Get-Help ...\test.ps1 -Full"
Actual behavior
> Get-Help .\test.ps1
test.ps1 [[-SampleParam] <Object>]
Environment data
Name Value
---- -----
PSVersion 7.1.0-preview.7
PSEdition Core
GitCommitId 7.1.0-preview.7-10-g3effa204103460c996a8612aa70718fdf924047d
OS Microsoft Windows 10.0.18363
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Trying to add script notes (Get-Help) but not working
Solution: Looks like the issue is coming from you using .SYNTAX, which isn't a legal keyword for comment based help.
Read more >How to enable a PowerShell script to return help text when ...
1 Answer 1 ... To clairfy, just copy and paste this to the top of your script. You can also do this for...
Read more >Get-Help (Microsoft.PowerShell.Core)
To get help for a script that isn't located in a path that's listed in the $env:Path environment variable, type the script's path...
Read more >Troubleshooting | Apps Script
There is an error in your script that doesn't have a corresponding error message. Try debugging your script and see if you can...
Read more >Choosing and Setting a PowerShell Execution Policy
With this policy set, your computer will run those PowerShell scripts that are accompanied by a valid signed with a valid digital signature...
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

I wish that Help was more intelligent - and gave an error when it fails rather than no output.
Comment based help must be the first or last thing in the file or in the block for a function, so it comes before the using statement
Works.
Gives no help
Works.
I would be careful with a change like this which will enable some behavior in new versions but neither works nor errors/warns in old ones. It seems logical to say those things should be allowed in any order. However when someone takes a script with an order which works in 7.1 and tries to run it on an earlier version they will go crazy trying to figure out why it doesn’t work in Windows PowerShell or in something with PowerShell 7.0.2 embedded (like .NET interactive) .
The rules that
usingcan be preceded by comments, and comment based help must be first or last have been there since the features were introduced.