I have a loop like below. In that, I want to compare next iteration value with current iteration value. If current value is not match with next value then I need to do some process. So I want to know like how to get the next Iteration value of a loop in powershell.
$var = (‘abc’,‘abc’,‘bcd’,‘cdf’,‘cdf’)
Foreach($i in $var){
If($i -ne $nextiterationvalue)
{
do something
}
else
{
do something
}
}