Это должно быть что-то чрезвычайно простое, но я просто не могу заставить Get-Help
работать из моего скрипта PowerShell.
- Когда я запускаю
Get-Help myscript -Examples
в командном окне PowerShell, я получаю отличное справочное сообщение. Тем не менее,
- Когда я вызываю
Get-Help myscript -Examples
в моем скрипте PowerShell, он запускается, как если бы -Examples
не указывалось - вместо справки примеров показывается обычная справка.
UPDATE:
Поскольку у @lit есть подозрения, причина в том, что я запускаю Get-Help для того же сценария, который в данный момент выполняется.
Я просто хочу показать справочное сообщение для моего скрипта. Вот пример, который вы можете попробовать:
<#
.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.