Skip to content

How to Delete a File in Powershell

Last updated on December 5, 2022

You can delete one or more files/folders in PowerShell using the Remove-Item cmdlet. It can delete many different types of items, including files, folders, registry keys, variables, aliases, and functions.

Delete a file from PowerShell

Just by, passing the file path to the Remove-Item cmdlet, you can delete the file via PowerShell.

Remove-Item C:\tutorials\testFile.txt

Delete Multiple files using PowerShell

You can delete as many files as you want with one Remove-Item command. You need to add the files separated by a comma. Let’s see the example below.

Remove-Item C:\tutorials\testFile.txt, C:\tutorials\testFile1.txt, C:\tutorials\testFile2.txt

Deleting folder using PowerShell

To delete a folder called c:\Test Folder

Remove-Item 'C:\Test Folder'

Delete folders and files recursively

To delete folders and files recursively

Remove-Item 'C:\Test Folder' -Recurse
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments