Powershell Comment-Based Help for scripts












1















I'm unable to access Comment-Based Help in my script.



The command I'm using is this:



PS C:MyDir> Get-Help .do-something.ps1 -Full
(do-something.ps1 is in MyDir).



My question is:



Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?



I've reviewed the Microsoft Documentation and distilled the following. Have I missed anything? Are there any scenarios where Comment-Based Help simply does not work?



PowerShell will NOT parse Comment-Based help for a script unless:




  1. The Comment-Based Help section begins on the first line of the
    script, or is preceded only by blank lines.


  2. There are at least two blank lines after the Comment-Based Help section if it's followed by a Function declaration.


  3. The script file is in a directory that is in $env:PATH. You must use -Path parmeter if it is not in $env:Path.


  4. Only valid Comment-Based Help keywords are used. If you misspell one, the Get-Help command will fail silently without any error.


  5. The Get-Help command uses correct syntax, for example:



PS C:MyDir> Get-Help .do-something.ps1 -Full




  1. The Comment-Based Help section is formatted properly, for example:


Positioned at top of script file:



<#
.SYNOPSIS
Does something.

.DESCRIPTION
Performs tasks and produces output.
#>









share|improve this question

























  • if it works in powershell.exe, then it almost always works in the ISE. the other direction has a larger chance of failure. [grin] can you post a working code sample? the ISE may be parsing more rigidly ...

    – Lee_Dailey
    Nov 23 '18 at 20:35











  • Perhaps I'm not using the command properly? I've issued the command just as described in my post. The output I receive is what you would get if you just issued the command Get-Help without any arguments.

    – jott19
    Nov 23 '18 at 23:45











  • without code to check, there is no way to determine the cause of the glitch. it SHOULD work the same in both the standard ISE console and the standard powershell.exe console. there are other consoles, tho ...

    – Lee_Dailey
    Nov 23 '18 at 23:50
















1















I'm unable to access Comment-Based Help in my script.



The command I'm using is this:



PS C:MyDir> Get-Help .do-something.ps1 -Full
(do-something.ps1 is in MyDir).



My question is:



Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?



I've reviewed the Microsoft Documentation and distilled the following. Have I missed anything? Are there any scenarios where Comment-Based Help simply does not work?



PowerShell will NOT parse Comment-Based help for a script unless:




  1. The Comment-Based Help section begins on the first line of the
    script, or is preceded only by blank lines.


  2. There are at least two blank lines after the Comment-Based Help section if it's followed by a Function declaration.


  3. The script file is in a directory that is in $env:PATH. You must use -Path parmeter if it is not in $env:Path.


  4. Only valid Comment-Based Help keywords are used. If you misspell one, the Get-Help command will fail silently without any error.


  5. The Get-Help command uses correct syntax, for example:



PS C:MyDir> Get-Help .do-something.ps1 -Full




  1. The Comment-Based Help section is formatted properly, for example:


Positioned at top of script file:



<#
.SYNOPSIS
Does something.

.DESCRIPTION
Performs tasks and produces output.
#>









share|improve this question

























  • if it works in powershell.exe, then it almost always works in the ISE. the other direction has a larger chance of failure. [grin] can you post a working code sample? the ISE may be parsing more rigidly ...

    – Lee_Dailey
    Nov 23 '18 at 20:35











  • Perhaps I'm not using the command properly? I've issued the command just as described in my post. The output I receive is what you would get if you just issued the command Get-Help without any arguments.

    – jott19
    Nov 23 '18 at 23:45











  • without code to check, there is no way to determine the cause of the glitch. it SHOULD work the same in both the standard ISE console and the standard powershell.exe console. there are other consoles, tho ...

    – Lee_Dailey
    Nov 23 '18 at 23:50














1












1








1








I'm unable to access Comment-Based Help in my script.



The command I'm using is this:



PS C:MyDir> Get-Help .do-something.ps1 -Full
(do-something.ps1 is in MyDir).



My question is:



Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?



I've reviewed the Microsoft Documentation and distilled the following. Have I missed anything? Are there any scenarios where Comment-Based Help simply does not work?



PowerShell will NOT parse Comment-Based help for a script unless:




  1. The Comment-Based Help section begins on the first line of the
    script, or is preceded only by blank lines.


  2. There are at least two blank lines after the Comment-Based Help section if it's followed by a Function declaration.


  3. The script file is in a directory that is in $env:PATH. You must use -Path parmeter if it is not in $env:Path.


  4. Only valid Comment-Based Help keywords are used. If you misspell one, the Get-Help command will fail silently without any error.


  5. The Get-Help command uses correct syntax, for example:



PS C:MyDir> Get-Help .do-something.ps1 -Full




  1. The Comment-Based Help section is formatted properly, for example:


Positioned at top of script file:



<#
.SYNOPSIS
Does something.

.DESCRIPTION
Performs tasks and produces output.
#>









share|improve this question
















I'm unable to access Comment-Based Help in my script.



The command I'm using is this:



PS C:MyDir> Get-Help .do-something.ps1 -Full
(do-something.ps1 is in MyDir).



My question is:



Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?



I've reviewed the Microsoft Documentation and distilled the following. Have I missed anything? Are there any scenarios where Comment-Based Help simply does not work?



PowerShell will NOT parse Comment-Based help for a script unless:




  1. The Comment-Based Help section begins on the first line of the
    script, or is preceded only by blank lines.


  2. There are at least two blank lines after the Comment-Based Help section if it's followed by a Function declaration.


  3. The script file is in a directory that is in $env:PATH. You must use -Path parmeter if it is not in $env:Path.


  4. Only valid Comment-Based Help keywords are used. If you misspell one, the Get-Help command will fail silently without any error.


  5. The Get-Help command uses correct syntax, for example:



PS C:MyDir> Get-Help .do-something.ps1 -Full




  1. The Comment-Based Help section is formatted properly, for example:


Positioned at top of script file:



<#
.SYNOPSIS
Does something.

.DESCRIPTION
Performs tasks and produces output.
#>






powershell syntax help-system






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 22:33









mklement0

131k20245282




131k20245282










asked Nov 23 '18 at 20:23









jott19jott19

7610




7610













  • if it works in powershell.exe, then it almost always works in the ISE. the other direction has a larger chance of failure. [grin] can you post a working code sample? the ISE may be parsing more rigidly ...

    – Lee_Dailey
    Nov 23 '18 at 20:35











  • Perhaps I'm not using the command properly? I've issued the command just as described in my post. The output I receive is what you would get if you just issued the command Get-Help without any arguments.

    – jott19
    Nov 23 '18 at 23:45











  • without code to check, there is no way to determine the cause of the glitch. it SHOULD work the same in both the standard ISE console and the standard powershell.exe console. there are other consoles, tho ...

    – Lee_Dailey
    Nov 23 '18 at 23:50



















  • if it works in powershell.exe, then it almost always works in the ISE. the other direction has a larger chance of failure. [grin] can you post a working code sample? the ISE may be parsing more rigidly ...

    – Lee_Dailey
    Nov 23 '18 at 20:35











  • Perhaps I'm not using the command properly? I've issued the command just as described in my post. The output I receive is what you would get if you just issued the command Get-Help without any arguments.

    – jott19
    Nov 23 '18 at 23:45











  • without code to check, there is no way to determine the cause of the glitch. it SHOULD work the same in both the standard ISE console and the standard powershell.exe console. there are other consoles, tho ...

    – Lee_Dailey
    Nov 23 '18 at 23:50

















if it works in powershell.exe, then it almost always works in the ISE. the other direction has a larger chance of failure. [grin] can you post a working code sample? the ISE may be parsing more rigidly ...

– Lee_Dailey
Nov 23 '18 at 20:35





if it works in powershell.exe, then it almost always works in the ISE. the other direction has a larger chance of failure. [grin] can you post a working code sample? the ISE may be parsing more rigidly ...

– Lee_Dailey
Nov 23 '18 at 20:35













Perhaps I'm not using the command properly? I've issued the command just as described in my post. The output I receive is what you would get if you just issued the command Get-Help without any arguments.

– jott19
Nov 23 '18 at 23:45





Perhaps I'm not using the command properly? I've issued the command just as described in my post. The output I receive is what you would get if you just issued the command Get-Help without any arguments.

– jott19
Nov 23 '18 at 23:45













without code to check, there is no way to determine the cause of the glitch. it SHOULD work the same in both the standard ISE console and the standard powershell.exe console. there are other consoles, tho ...

– Lee_Dailey
Nov 23 '18 at 23:50





without code to check, there is no way to determine the cause of the glitch. it SHOULD work the same in both the standard ISE console and the standard powershell.exe console. there are other consoles, tho ...

– Lee_Dailey
Nov 23 '18 at 23:50












1 Answer
1






active

oldest

votes


















1















Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?




Yes. Comment-based help is parsed by PowerShell (system.management.automation.dll), not the host.




Are there any scenarios where Comment-Based Help simply does not work?




Comment-based help only works if the script can be executed. If the execution policy or application control like AppLocker prohibits the execution of the script, or if you have a syntax error in the script, Get-Help cannot display the comment-based help.






share|improve this answer


























  • I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

    – jott19
    Nov 23 '18 at 23:57











  • The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

    – jott19
    Nov 24 '18 at 18:49











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452568%2fpowershell-comment-based-help-for-scripts%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1















Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?




Yes. Comment-based help is parsed by PowerShell (system.management.automation.dll), not the host.




Are there any scenarios where Comment-Based Help simply does not work?




Comment-based help only works if the script can be executed. If the execution policy or application control like AppLocker prohibits the execution of the script, or if you have a syntax error in the script, Get-Help cannot display the comment-based help.






share|improve this answer


























  • I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

    – jott19
    Nov 23 '18 at 23:57











  • The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

    – jott19
    Nov 24 '18 at 18:49
















1















Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?




Yes. Comment-based help is parsed by PowerShell (system.management.automation.dll), not the host.




Are there any scenarios where Comment-Based Help simply does not work?




Comment-based help only works if the script can be executed. If the execution policy or application control like AppLocker prohibits the execution of the script, or if you have a syntax error in the script, Get-Help cannot display the comment-based help.






share|improve this answer


























  • I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

    – jott19
    Nov 23 '18 at 23:57











  • The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

    – jott19
    Nov 24 '18 at 18:49














1












1








1








Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?




Yes. Comment-based help is parsed by PowerShell (system.management.automation.dll), not the host.




Are there any scenarios where Comment-Based Help simply does not work?




Comment-based help only works if the script can be executed. If the execution policy or application control like AppLocker prohibits the execution of the script, or if you have a syntax error in the script, Get-Help cannot display the comment-based help.






share|improve this answer
















Should I expect this command to work the same in the ISE Console Pane as well as the PS Console?




Yes. Comment-based help is parsed by PowerShell (system.management.automation.dll), not the host.




Are there any scenarios where Comment-Based Help simply does not work?




Comment-based help only works if the script can be executed. If the execution policy or application control like AppLocker prohibits the execution of the script, or if you have a syntax error in the script, Get-Help cannot display the comment-based help.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 23 '18 at 22:30









mklement0

131k20245282




131k20245282










answered Nov 23 '18 at 21:49









vrdsevrdse

1,731213




1,731213













  • I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

    – jott19
    Nov 23 '18 at 23:57











  • The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

    – jott19
    Nov 24 '18 at 18:49



















  • I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

    – jott19
    Nov 23 '18 at 23:57











  • The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

    – jott19
    Nov 24 '18 at 18:49

















I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

– jott19
Nov 23 '18 at 23:57





I do have Set-StrictMode -Version 2.0 set in the script - there may be some variables that cannot be set due to unavailability of files used for processing. Or perhaps a loaded module it causing it to fail? I will do more testing...

– jott19
Nov 23 '18 at 23:57













The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

– jott19
Nov 24 '18 at 18:49





The problem was the script was not executable. This was the one item I omitted in the list of requirements posted in my original question.

– jott19
Nov 24 '18 at 18:49




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53452568%2fpowershell-comment-based-help-for-scripts%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wiesbaden

Marschland

Dieringhausen