Hi @DevP ,
It's not supported to use add/delete/update method inside foreach loop, otherwise you would get this error.
You need to use for loop instead to achieve this:
For($i=0; $i -lt $web.Lists.count; $i++)
{
if($web.Lists[$i].Title -eq $masterTasks)
{
write-host "`n`tMaster Tasks list found"
For($j=0; $j -lt $list.Views.Count; $j++)
{
$view=$list.Views[$j]
$view.JSLink = $jSFile
$view.Update()
}
}
if($web.Lists[$i].Title -eq $allTasks)
{
write-host "`n`tAll Tasks list found"
#Iterating views
For($j=0; $j -lt $list.Views.Count; $j++)
{
$view= $list.Views[$k]
$view.JSLink = $jSFile
$view.Update()
}
}
}
If an Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.