I have a PowerShell function that basically looks like this:
function DoSomething-ToTask {
[cmdletbinding()]
param(
[parameter(Mandatory=$t
Yes, you can use the ValueFromRemainingArguments
parameter attribute.
function DoSomething-ToTask {
[cmdletbinding()]
param(
[Parameter(Mandatory=$true, ValueFromRemainingArguments = $true)]
[int[]]$TaskNums
)
foreach ($TaskNum in $TaskNums) {
do something $TaskNum
}
}
Here is a working example:
function Do-Something {
[CmdletBinding()]
param (
[Parameter(ValueFromRemainingArguments = $true)]
[int[]] $TaskNumber
)
foreach ($Item in $TaskNumber) {
Write-Verbose -Message ('Processing item: {0}' -f $Item);
}
}
Do-Something 1 2 3 -Verbose;
Result: