Use PowerShell to Delete a Single File or Folder

Before start executing the Delete powershell command we need to make sure you are logged in to the server or PC with an account that has full access to the objects you want to delete.

The above command will excute and delete the “DummyfiletoDelete.txt” file which present inside the “C:\dotnet-helpers” location.

Use PowerShell to Delete all File and Folders inside the folder

We can also use wildcard ‘*’ characters to remove multiple items. For example, this command removes all the files in “C:\dotnet-helpers\*.*”

Recurse drills down and finds lots more files. The โ€“recurse parameter will allow PowerShell to remove any child items without asking for permission. Additionally, the โ€“force parameter can be added to delete hidden or read-only files.

Using -Force command to delete files force fully

The above command will delete all hidden or read-only files from the location “C:\dotnet-helpers\”