In Powershell specify path to delete specify *.csv files

In Powershell, how can I specify to look at a specific path, such as  C:\folder\files\....  and if it sees any files that end with either *.csv, or end/preceded by rev_csv, but leave other files intact?
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.

With a Get-ChildItem and a filter. "BaseName" is the name of the file without extension.
This is in test mode and will only show the files it would delete. Remove the -WhatIf at the end to run it for real:
Get-ChildItem -File -Path C:\folder\files | Where-Object {($_.Extension -eq '.csv') -or ($_.BaseName -like 'rev_csv*') -or ($_.BaseName -like '*rev_csv'} | Remove-Item -Force -WhatIf

Open in new window

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
You could try this :

Function invoke-remove-specified_csv($FolderLocation){
#$FolderLocation = "c:\folder\files\"

$filesFound = Get-ChildItem -Path $FolderLocation |? {(($_ -like "*csv*") -or ($_ -like "*rev_csv*"))}
write-host -ForegroundColor Green "The following Files were Found : Press any key to Remove them or press Ctrl C to end."
write-host "Removing Files Specified"
$filesFound |Remove-Item

Open in new window

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.