following is my code:
foreach($field in $list.Fields)
{
if($field.StaticName -eq "temp1" -or $field.StaticName -eq "temp2")
{
if($field.Id -ne $depId)
{
$field.AllowDeletion = $true
$field.Delete()
$list.Update()
}
}
else
{
if($field.StaticName -eq "notActive" -and $field.Id -ne $aktId)
{
$field.AllowDeletion = $true
$field.Delete()
$list.Update()
}
}
}
but it generates, Collection was modified; enumeration operation may not execute.