$linesToRemove = @( '', '', '' ) Get-ChildItem -Path . -Filter "*.php" | ForEach-Object { $file = $_.FullName $content = Get-Content $file | Where-Object { $_ -notin $linesToRemove } $content | Set-Content $file -Encoding UTF8 }