How to delete a file or folder in Powershell

To delete a file or Folder in Powershell you can use the following snippet.

Sample Powershell

if you want to delete a file use

remove-item -path "C:\Users\Codesnippets\Desktop\Test.xml" -force -recurse

if you want to delete a folder use

remove-item -path "C:\Users\Codesnippets\Desktop\Folder1" -force -recurse

for more informations see Using the Remove-Item Cmdlet

Please Share us:
Please rate this snippet

One thought on “How to delete a file or folder in Powershell

Leave a Reply