「PowerShell」関数(function)を使うサンプル

2020年12月21日

書式
function 関数名A{}
function 関数名B(変数1,変数2)
使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#基本関数 引数なし
function testFunc {
echo "this is a function test"
}
testFunc
#引数あり 関数
function testFuncB($cftA, $cftB) {
echo ('$cftA value: ' + $cftA + , ' $cftB value: ' + $cftB)
}
testFuncB 'study skill' 'in arkgame.com'
#基本関数 引数なし function testFunc { echo "this is a function test" } testFunc #引数あり 関数 function testFuncB($cftA, $cftB) { echo ('$cftA value: ' + $cftA + , ' $cftB value: ' + $cftB) } testFuncB 'study skill' 'in arkgame.com'
#基本関数 引数なし
function testFunc {
    echo "this is a function test"
}
testFunc

#引数あり 関数
function testFuncB($cftA, $cftB) {
    echo ('$cftA value:  ' + $cftA + , ' $cftB  value:  ' + $cftB)
}

testFuncB 'study skill' 'in arkgame.com'

実行結果
> ./test.ps1
this is a function test
$cftA value: study skill$cftB value: in arkgame.com

PowerShell

Posted by arkgame