나는 -h
값을 전달하지 않고 -h
매개 변수와 함께 사용하고자합니다 : 그러나 나머지는 어떻게 유지하고 싶은가요 ... 즉, 선택 사항입니다. 매개 변수의 별명을 지정하지 않고 값을 제공해야하는 경우가 아니면powershell에서 별칭을 사용하는 빈 매개 변수
Param(
$BadParam,
[alias("h")][String]$Help,
[alias("s")][String]$Server,
[alias("d")][String]$DocRoot,
[alias("c")][String]$Commit,
[alias("b")][String]$Branch
)
예를 들어 (더 나은의 부족) :
if(!$Help)
{
Write-Host "Here's the menu for how it works bro."
}
if($Help)
{
Write-Host "Here's more info on that particular thing from the menu."
}
것은 나는이 쉘에서 행동을 기대 방법 :
-> script.ps1 -s test -h
-> Here's the menu for how it works bro.
-> script.ps1 -s test -h server
-> Here's more info on that particular thing from the menu.
-> script.ps1 -s -h server
-> You are missing a value for -e.