windows powershell to delete files

I want a windows powerschell script to delete all files with names ending with _1.
gram77Asked:
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.

Kurt4949Commented:
Try something like this

PS C:\temp> remove-item * -include *_1.*
0
gram77Author Commented:
Where do i run this command.
I run it in cmd.

I get error:
'Remove-Item' is not recognized as an internal or external command,
operable program or batch file.
0
Kurt4949Commented:
You need to run it in powershell.  Click start and in the search box, type powershell.

Another example with folder name: remove-item c:\Temp\* -include *_1.*
0
Newly released Acronis True Image 2019

In announcing the release of the 15th Anniversary Edition of Acronis True Image 2019, the company revealed that its artificial intelligence-based anti-ransomware technology – stopped more than 200,000 ransomware attacks on 150,000 customers last year.

gram77Author Commented:
Incidently the script didn't do anything
Remove-Item -path "C:\Users\Me\Pictures" -include *_1.*

or

Remove-Item -path 'C:\Users\Me\Pictures' -include *_1.*
0
Kurt4949Commented:
Remove-Item C:\Users\Me\Pictures\* -include *_1.*
0
gram77Author Commented:
First of all i would want to see what file windows is selecting to delete, and then delete them
0
Kurt4949Commented:
If you have a space in your username then follow this example.

PS C:\> remove-item "C:\Temp\New Folder\*" -include *_1.*

You could just create a test folder and add a few files like I did in my example.
0
Kurt4949Commented:
Also try adding -Confirm and it will prompt you before deleting the files.

PS C:\> remove-item "C:\Temp\New Folder\*" -include *_1.* -Confirm
0

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
Microsoft Legacy OS

From novice to tech pro — start learning today.