It must be something extremely simple but I just can't make Get-Help work from within my PowerShell script.
- When I run
Get-Help myscript -Examplesin PowerShell command window, I get perfect help message. However, - When I call
Get-Help myscript -Examplesin my PowerShell script, it runs as if that the-Examplesis not specified -- the normal help is shown, instead of the examples help.
UPDATE:
As @lit has suspect, the reason is that, I'm running Get-Help on the same script that is currently running.
I just want to show help message for for my script. Here is an example you can try out:
<#
.SYNOPSIS
Calculates the number of possible passwords
.DESCRIPTION
Calculates the number of possible passwords based
on the input so you will know the actual number before
you proceed to create your dictionary file.
.PARAMETER CharacterSet
Specifies the characters (letters, numbers, symbols) that
need to be included. Parameter is mandatory.
.PARAMETER MinCharacters
Specifies the minimum characters of the generated passwords.
Parameter is mandatory.
.PARAMETER MaxCharacters
Specifies the maximum characters of the generated passwords.
Parameter is mandatory.
.PARAMETER IncludeCapital
Specifies whether or not to include upper case letters along with
the lower case letters.
.PARAMETER CapitalOnly
Specifies whether or not all lower case letters to be converted to
upper case letters.
.INPUTS
System.String. Get-PasswordNumber can accept a string value to
determine the CharacterSet parameter.
.OUTPUTS
System.Double. Get-PasswordNumber returns the number of passwords that
can be created.
.EXAMPLE
C:\PS> Get-PasswordNumber -CharacterSet "a,b,c,1,2,3,$,*,&" -MinCharacters 2 -MaxCharacters 5
66420
.EXAMPLE
C:\PS> Get-PasswordNumber -Characters "a,b,c,1,2,3,$,*,&" -MinCharacters 2 -MaxCharacters 5 -IncludeCapital
271440
.EXAMPLE
C:\PS> Get-PasswordNumber -Characters "a,b,c,1,2,3,$,*,&" -MinCharacters 2 -MaxCharacters 5 -CapitalOnly
66420
.EXAMPLE
C:\PS> Get-PasswordNumber -Characters alphabet -MinCharacters 2 -MaxCharacters 5
12356604
.LINK
PowerShell Module DictionaryFile
#>
param(
[switch]$IncludeCapital,
[switch]$CapitalOnly)
write-host program started.
if (!$CapitalOnly) {
Get-Help myscript
Get-Help myscript -Examples
}
write-host program ended.