반응형
Powershell 스크립트 파라미터 도움말메시지를 표시하려면 어떻게 해야 하나요?
powershell 스크립트를 가지고 있습니다.setup.ps1개발 환경 셋업 스크립트의 엔트리 포인트로 사용합니다.다음 파라미터를 사용합니다.
param(
[Parameter(Position=0,HelpMessage="The targets to run.")]
[Alias("t")]
[string[]]
$Targets = "Help"
)
내가 달릴 때
PS > get-help .\setup.ps1 -detailed
[ Parameters ]섹션에 도움말메시지가 표시되지 않습니다.
PARAMETERS
-Targets <String[]>
파라미터 도움말메시지를 표시하려면 어떻게 해야 하나요?
파일 맨 위에 PowerShell 도움말 시스템으로 디코딩할 수 있는 특정 스타일의 코멘트를 붙입니다.다음은 예를 제시하겠습니다.
<#
.SYNOPSIS
.
.DESCRIPTION
.
.PARAMETER Path
The path to the .
.PARAMETER LiteralPath
Specifies a path to one or more locations. Unlike Path, the value of
LiteralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in single
quotation marks. Single quotation marks tell Windows PowerShell not to
interpret any characters as escape sequences.
.EXAMPLE
C:\PS>
<Description of example>
.NOTES
Author: Keith Hill
Date: June 28, 2010
#>
function AdvFuncToProcessPaths
{
[CmdletBinding(DefaultParameterSetName="Path")]
param(
[Parameter(Mandatory=$true, Position=0, ParameterSetName="Path",
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to ...")]
[ValidateNotNullOrEmpty()]
[string[]]
$Path,
[Alias("PSPath")]
[Parameter(Mandatory=$true, Position=0, ParameterSetName="LiteralPath",
ValueFromPipelineByPropertyName=$true,
HelpMessage="Path to ...")]
[ValidateNotNullOrEmpty()]
[string[]]
$LiteralPath
)
...
자세한 내용은 다음 도움말 항목을 참조하십시오.man about_comment_based_help.
도움말 헤더가 정의되어 있는 경우 파라미터 뒤에 주석(#)을 사용할 수 있습니다(이 예에서는 #targets to run).
<#
.SYNOPSIS
.
.DESCRIPTION
.
.PARAMETER Path
The path to the .
.PARAMETER LiteralPath
Specifies a path to one or more locations. Unlike Path, the value of
LiteralPath is used exactly as it is typed. No characters are interpreted
as wildcards. If the path includes escape characters, enclose it in single
quotation marks. Single quotation marks tell Windows PowerShell not to
interpret any characters as escape sequences.
#>
Param(
[String]$Targets = "Help" #The targets to run.
)
결과:
PS C:\> Get-help .\Setup.ps1 -Detailed
NAME
C:\Setup.ps1
SYNOPSIS
.
SYNTAX
C:\Setup.ps1 [[-Targets] <String>] [<CommonParameters>]
DESCRIPTION
.
PARAMETERS
-Targets <String>
The targets to run.
파일 상단에 있는 부분만 있으면 작동하므로 파라미터에 인라인 코멘트를 할 수 있습니다.
<# .SYNOPSIS #>
param(
[String]$foo ## my 1st cool param
,[Switch]$bar ## my 2nd crazy switch
)
...
(확인 완료)PS 5.1.14409.1018)
언급URL : https://stackoverflow.com/questions/5237723/how-do-i-get-help-messages-to-appear-for-my-powershell-script-parameters
반응형
'programing' 카테고리의 다른 글
| 최적의 WPF 오픈 소스 프로젝트 (0) | 2023.04.20 |
|---|---|
| WPF - 명령어가 명령어 바인딩을 통해 'CanExecute'를 재평가하도록 강제하는 방법 (0) | 2023.04.20 |
| MVVM을 사용하여 WPF에서 선택한 확인란을 기반으로 텍스트 상자 사용/사용 안 함 (0) | 2023.04.20 |
| 개인 git repo를 도커 파일로 복제 (0) | 2023.04.20 |
| 테이블 값 함수(TVF)와보다 (0) | 2023.04.20 |