I get an error when trying to use multiple commands in the <Init> part of a for loop in Powershell. For example,
function Example {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)] [int] $Base,
[Parameter(Mandatory=$True)] [int] $Count
)
Process {
for ( $item = 1, $id = $Base; $item -le $Count; $id++, $item++ ) {
}
}
}
Example -Base 1 -Count 2
The Microsoft documentation says that <Init> "represents one or more commands" and that <Repeat> "represents one or more commands, separated by commas". The wording is different, so I realize that the syntax may be different.
The error I get is "The assignment expression is not valid. The input to an assignment operator must be an object that is able to accept assignments, such as a variable or a property." with the underscore beneath the 1 in "$item = 1".