How do I read command line arguments in Powershell into an array? Something like
myprogram -file file1 -file file2 -file file3
and then I have an array of
[file1,file2,file3]
Similar question for hash. Thanks.
How do I read command line arguments in Powershell into an array? Something like
myprogram -file file1 -file file2 -file file3
and then I have an array of
[file1,file2,file3]
Similar question for hash. Thanks.
Command line arguments are stored in an array by default. The array is $args[]. If you want named parameters, use param(). If you want to specify multiple arguments for the same parameter, use commas.
Example code:
function myprogram {
param (
[string[]]$file
)
#Do stuff to $file array here
}
Command line:
myprogram -file file1,file2,file3