This post explains how to delete files and folders using PowerShell command ‘Remove-Item’. Also we are going to cover deleting of multiple files and removing files with wild characters.
For a single file:
Remove-Item test.txt
Code language: CSS (css)
For multiple files:
Remove-Item test1.txt test2.txt test3.txt
Code language: CSS (css)
For files with wild characters
Remove-Item *.txt
or
Remove-Item *.xls
and so on
Code language: CSS (css)
To delete a directory
Remove-Item foldertodelete
It will ask you if you want to delete the whole content select “Y” for yes and press enter.