「PowerShell」引数と戻り値あり関数のサンプル
書式
function 関数名($引数…) {処理コード}
関数を呼び出します
関数名 値1 値2…
使用例
function funcA($cftA,$cftB){
$result = $cftA * $cftB
return $result
}
$cft = funcA 8 10
Write-Host $cft
function funcA($cftA,$cftB){
$result = $cftA * $cftB
return $result
}
$cft = funcA 8 10
Write-Host $cft
function funcA($cftA,$cftB){ $result = $cftA * $cftB return $result } $cft = funcA 8 10 Write-Host $cft
実行結果
PS C:\study\powershell> .\test.ps1
80
PS C:\study\powershell> .\test.ps1
80
PS C:\study\powershell> .\test.ps1 80