Command referenceRemove-Item
Remove-Item command (Windows / PowerShell)
What it does
Delete provider items such as files, directories, registry keys, and variables. Guides covering the remove-item powershell safely usually need pipeline-friendly examples, common parameters, and how the cmdlet compares with classic CMD or Linux tools. This page includes syntax, options, and copyable PowerShell examples.
Delete provider items such as files, directories, registry keys, and variables.
Syntax
Remove-Item [-Path] <String[]> [-Recurse] [-Force] [-Confirm] [-WhatIf]
Common options
| Flag / option | Meaning |
|---|---|
| -Recurse | Remove descendants of a container. |
| -Force | Include hidden or read-only items where supported. |
| -WhatIf | Preview intended removals. |
| -Confirm | Prompt before performing the operation. |
| -LiteralPath | Treat wildcard characters literally. |
Practical examples
Preview cleanup
Remove-Item .\*.tmp -WhatIf
Shows matching deletions without changing files.
Confirm deletion
Remove-Item .\old.log -Confirm
Requests approval before deletion.
Remove known tree
Remove-Item .\TempBuild -Recurse
Deletes the selected temporary directory tree.
Linux ↔ Windows equivalent
Closest match: rm (Linux / bash / sh / zsh). Remove files and directory trees permanently.
Common mistakes
- Danger: combining `-Recurse` and `-Force` with a broad path can permanently erase a tree; run with `-WhatIf` first.
- Expecting removed files to enter the Recycle Bin.
- Using `-Path` for names containing wildcard characters instead of `-LiteralPath`.
Related commands
- Get-ChildItemEnumerate items and child items in filesystem, registry, and other providers.
- Copy-ItemCopy items between locations supported by PowerShell providers.
- delPermanently delete one or more files.
- lsList directory entries and inspect file metadata.
- cdChange the shell's current working directory.
- dirList files and subdirectories with names, dates, sizes, and attributes.
- findWalk directory trees and select entries using tests and actions.
- cdDisplay or change the current directory in Command Prompt.
FAQ
What does Remove-Item do in PowerShell?
Delete provider items such as files, directories, registry keys, and variables.
How can I see examples for Remove-Item?
Run `Get-Help Remove-Item -Examples`, then adapt an example to the provider and objects you are using.
What is a practical Remove-Item example?
Try `Remove-Item .\*.tmp -WhatIf` — Shows matching deletions without changing files.
Does Remove-Item return text or objects?
Remove-Item normally participates in PowerShell's object pipeline; formatting seen in the console is a view of those objects.
Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.