Import-CSV and remove specified values

I have a powershell script to export some account info from AD. I want to read this CSV file in and remove certain accounts. I can't do it dynamically as it's something a manager needs to specify. The CSV file output is below

"","UserF1","UserL1l","Cashiering","9/8/2006 11:33:53 AM"
"","UserF2","UserL2l","Cashiering","9/13/2006 11:50:59 AM"
"","UserF3","UserL3l","Cashiering","12/6/2012 2:51:43 PM"
"","UserF4","UserL4l","Cashiering","12/6/2012 2:51:43 PM"

I'd like to be able to loop through a where clause and remove lines based on "Email address" I specify in the file. I forsee the need to add additonal accounts in the future so if I could use an array of some sort that would be best. I see a couple solutions online but not quite what I need. logic would be

Import CSV

If account is in the list below, remove the line from the CSV

Export-CSV Contents

any help is appreciated!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
$ignore = @"
"@ -split "`r`n"

(Get-Content file.txt  | Select-String -NotMatch -SimpleMatch $ignore) | Out-File file2.txt

Open in new window

As I suppose comparing parts of the line with the email addresses is enough of a match to reliable exclude the unwanted lines. We can make the pattern more restrictive, or switch to your suggestion handling CSV data, if required.
jbla9028Author Commented:
Sorry for the delay, I was on vacation. I tried to add this statement but it's not removing the line from the CSV file. it's just outputing the same exact text file it read back in.
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
There seems to be an EE issue with the backtick used, I suspect. Let's try something slightly different:
$ignore = '',

(Get-Content file.txt  | Select-String -NotMatch -SimpleMatch $ignore) | Out-File file2.txt

Open in new window

jbla9028Author Commented:
]Thank you for the help again. So this time the user was removed but the CSV file structure was manipulated in a way that makes it unusable. For some reason records are now traversing multiple lines in the CSV file.

CSV Prior

CSV Post
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
That has to be an issue with the app you use to read the file. Test with two entries only, and compare the files with a standard editor, then with the app.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.