Delete a Folder in PowerShell With a Preview First

PowerShell deletes a folder with Remove-Item; add -Recurse when its contents must go too. Start with -LiteralPath and -WhatIf so you can check the exact target before allowing deletion.

Deleting a folder also removes the folder itself; emptying it leaves the folder in place. The command in this guide removes the named folder itself, including its contents. It skips File Explorer's normal Recycle Bin route.

1. Pick the complete folder path before writing the command

Find the parent folder in Explorer, then confirm the target folder's name. Copy its full path, including its drive letter. Decide which folder to remove before editing the command, especially if you're working somewhere unfamiliar.

Keep a backup of anything you might need. Remove-Item doesn't provide File Explorer's normal Recycle Bin recovery route. A path checked before deletion is far more useful than a recovery attempt afterward.

Drawing of PowerShell showing a Remove-Item preview command with LiteralPath, Recurse, and WhatIf

A full path starts with the drive and location, such as C:\Work\Old material. A relative path depends on the shell's current folder. A complete path makes it clear which folder you're targeting.

If you're still learning how the prompt's location works, the PowerShell directory guide explains it. For this deletion, you don't need to change directories when you've supplied the complete path.

Open Windows PowerShell from Start, or open a PowerShell tab in Terminal. The same basic Remove-Item command works in Windows PowerShell 5.1 and PowerShell 7 on Windows 10 or 11.

Start in a normal window. Deleting a folder where your account can already make changes usually needs no extra permissions. A protected Windows directory is a different job, and its permissions shouldn't be changed to make an example work.

2. Inspect the selected folder without removing it

In these examples, C:\Work\Old material is an example path. Replace it with your folder's actual path before running anything. Keep the single quotes around the full path, especially when its name contains spaces.

First ask PowerShell to display the selected folder:

Get-Item -LiteralPath 'C:\Work\Old material'

Check the displayed location and name. If it returns a missing-path error, correct the path before you continue. A folder on a disconnected external drive or network share needs that connection restored first.

List the immediate contents when you need a final look:

Get-ChildItem -LiteralPath 'C:\Work\Old material' -Force

Here, Force includes hidden items in the listing. It doesn't delete them. Check for files you forgot were in the folder, particularly when the visible folder looked empty in Explorer.

Use -LiteralPath to target an exact folder name. It treats brackets and other wildcard characters as characters in the name. By contrast, -Path supports wildcard matching, which can select more than one item.

I'd use the literal form even for a simple name. You can use the same approach when next month's folder includes brackets, without worrying that those brackets will make the command select something else.

3. Preview the removal, then run the reviewed command

To remove a folder and everything inside it, preview the command first:

Remove-Item -LiteralPath 'C:\Work\Old material' -Recurse -WhatIf

-Recurse includes the files and subfolders inside the folder. -WhatIf reports the proposed action without carrying it out. Read the target path in the output; a successful preview doesn't mean every later permission check will succeed.

Once you've checked the folder and your backup, remove only -WhatIf from the command:

Remove-Item -LiteralPath 'C:\Work\Old material' -Recurse

Press Enter and let PowerShell finish the operation. PowerShell can delete the folder successfully without displaying a message. Check Explorer afterward rather than expecting a progress report for every file.

Microsoft's Remove-Item reference describes these parameters. This approach removes the directory itself, so it won't leave an empty folder with the original name.

For an empty folder, -Recurse isn't needed. When a folder has contents, use -Recurse only after deciding everything inside can go. Don't accept an unexpected contents prompt without checking the target.

4. Use Force for hidden items only when needed

If deletion reports a hidden or read-only item, and it's part of the folder you've already approved for removal, preview the command with Force:

Remove-Item -LiteralPath 'C:\Work\Old material' -Recurse -Force -WhatIf

After reviewing it, remove WhatIf to proceed. Force handles hidden and read-only file attributes. It doesn't override Windows security permissions, and it doesn't make a file available while another program holds it open.

For an access-denied message, check the item named in the error. Check whether you're removing your own files, an app's working data, or a folder managed by another account before deciding whether you need more permissions.

For a file-in-use message, close the document and the application using it, then retry. If PowerShell is inside that folder, change to another location first. That avoids keeping the target as your shell's working directory.

If the failure names only one child file, inspect that file instead of repeatedly trying to delete the whole folder. A partial deletion can leave the main folder in place after other contents have already been removed.

5. Check what remains and handle a failed removal

Check whether the target path still exists:

Test-Path -LiteralPath 'C:\Work\Old material'

False means PowerShell can't find an item at that exact path. True means an item is still there. When the result is True, list the contents again and read the earlier error to see what was left behind.

If pasting the PowerShell command is the problem, fix that before changing the command. Curly quotes, a missing apostrophe, or a copied prompt label can turn a valid example into a syntax error.

For a folder that belongs to your organization, send IT the path that failed for help with its permissions. Include the full error, plus any contents the command already removed.

For an app-managed backup folder, use that app's removal or retention controls first.

Don't use a more powerful deletion tool just because one file remains. The error message should decide the next action: correct the path, release an open file, or request the permissions needed for an approved deletion.

The Short Version

Inspect the literal folder path, preview Remove-Item -LiteralPath 'path' -Recurse -WhatIf, then remove WhatIf only after checking it. Use Force for approved hidden or read-only contents, and read any remaining error before retrying.

Checked December 3, 2026.

If you have any business, I can build it online

Hi, I’m Hamza. I’ve been building websites and online shops for business owners since 2019, and I also built this site you’re reading.

Tell me what business you have or what you’re working on. I’ll look into how much it can grow online, and then we talk. You don’t have to buy anything or hire me first.

Chat with me on my site and I’ll show you proof of businesses I’ve helped and how they’ve grown.

Written by Isaac Smith

Isaac Smith is the founder and editor of PC Glance, a website that covers computers, laptops, and technology. He is a tech enthusiast and a computer geek who loves to share his insights and help his readers make smart choices when buying tech gadgets or laptops. He is always curious and updated about the latest tech trends.

More from Isaac Smith

Leave a Comment