Powershell Deleting Files and Folders
Here is a quick list of very useful File and Folder Deletion operation command-lets.
Completely delete a folder along with files and sub-folders in it forcefully:
Remove-Item “C:TempFldr” -Force -Recurse -ErrorAction SilentlyContinue
Completely delete a files and sub-folder under the folder but retain the folder.
Remove-Item “C:TempFldr*” -Force -Recurse -ErrorAction SilentlyContinue
Delete only the files under the folder but not sub-folders and files in it.
Remove-Item “C:TempFldr*.*” -Force -Recurse -ErrorAction SilentlyContinue
Delete ONLY files recursively under the folder and sub-folders while retaining the folder structure.
forfiles /p C:temp-new /s /c “cmd /c if @isdir==FALSE del @file”