Передача параметров без значения в скрипт
Привет. Как передать в скрип параметр без значения к примеру -s (--silent) или -h (--help)? В интернете нашёл только
Код:
Param (
[Parameter (Mandatory=$true, Position=1)]
[string]$service,
[Parameter (Mandatory=$true, Position=2)]
[string]$computer
)
Как я понял здесь обязательно нужно указывать значения.
|
Код:
function Test{
Param (
[Parameter(Mandatory=$true, Position=1)]
[String]$Service
,
[Parameter(Mandatory=$true, Position=2)]
[String]$Computer
,
[Switch]$Silent
)
if(!$Silent){
Write-Host $Service $Computer
}
else{
"I can't talk :("
}
}
Test -Silent "Hello," "World!"
|
Serguei Kouzmine |
18-02-2021 16:54 2950584 |
такие параметры называются
|
Время: 16:36.
© OSzone.net 2001-