param
で受け取る
argstest.ps1
1 2 3 4 5 6 7 |
<span class="kr">param</span><span class="p">(</span> <span class="nv">$Args1</span><span class="p">,</span> <span class="nv">$Args2</span> <span class="p">)</span> <span class="nf">Write-Host</span> <span class="nt">-Object</span> <span class="nv">$Args1</span> <span class="nf">Write-Host</span> <span class="nt">-Object</span> <span class="nv">$Args2</span> |
実行
オプションパラメータもtab補完で出る
1 2 3 4 |
<span class="nf">PS</span> <span class="nx">W:\</span><span class="err">></span> <span class="o">.</span><span class="nx">\argstest.ps1</span> <span class="nt">-Args1</span> <span class="nx">aaa</span> <span class="nt">-Args2</span> <span class="nx">bbb</span> <span class="nf">aaa</span> <span class="nf">bbb</span> <span class="nf">PS</span> <span class="nx">W:\</span><span class="err">></span> |