2
1

More than 5 years have passed since last update.

Powershellで全引数引き渡し

Last updated at Posted at 2016-09-26

shellscriptの$@(全引数引き渡し)みたいなことをやりたくて書いてみたテストコード
一応できたけど、もう少しスマートなやり方がないかな

test.ps1
function test($a,$b){
   Write-Host "a:${a}"
   Write-Host "b:${b}"
   foreach($arg in $args){
      Write-Host $arg
   }
}
Invoke-Expression "test $($args -Join " ")"
. .\test.ps1 1 2 3 4
a:1
b:2
3
4
2
1
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1