![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | passing arguments PS C:\Documents and Settings\temp> $arg aaaa bbbb cccc PS C:\Documents and Settings\temp> $(& .\arg.ps1 $(foreach($a in $arg) { $a} ) ) arg1 = aaaa bbbb cccc arg2 = Currently it is passing all values in array $arg to the first argument (arg1) of args.ps1 - I would like to pass $arg values to all arguments incrementaly- what code that will be? ex: arg1 = aaaa arg2 = bbbb VB |
My System Specs![]() |
| | #2 (permalink) |
| | Re: passing arguments "VB" <truncho@yahoo.com> wrote in message news:Odncum1IHHA.1276@TK2MSFTNGP04.phx.gbl... > PS C:\Documents and Settings\temp> $arg > aaaa > bbbb > cccc > PS C:\Documents and Settings\temp> $(& .\arg.ps1 $(foreach($a in $arg) { > $a} ) ) > arg1 = aaaa bbbb cccc > arg2 = > > Currently it is passing all values in array $arg to the first argument > (arg1) of args.ps1 - I would like to pass $arg values to all arguments > incrementaly- what code that will be? > > ex: > arg1 = aaaa > arg2 = bbbb A way to address this is to declare the array explicitly in the param section of your script. Given the following script: --- words.ps1 param ([array]$words) $word1,$word2,$word3 = $words "`$word1 = $word1" "`$word2 = $word2" "`$word3 = $word3" You can then do this: PS> $arg = "hello","world","welcome","onboard" PS> .\words $arg $word1 = hello $word2 = world $word3 = welcome onboard Hope that helps, Jacques |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Passing Argument Names as arguments | PowerShell | |||
| Passing arguments to external command through PS | PowerShell | |||
| Need help - passing string arguments with quotes | PowerShell | |||
| Passing arguments into scripts? | PowerShell | |||
| Passing arguments to a function | PowerShell | |||