Skip to main content

Command referenceRemove-Item

Remove-Item command (Windows / PowerShell)

WindowsPowerShellfilebeginnerDestructive — use carefully

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 / optionMeaning
-RecurseRemove descendants of a container.
-ForceInclude hidden or read-only items where supported.
-WhatIfPreview intended removals.
-ConfirmPrompt before performing the operation.
-LiteralPathTreat 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`.

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.