2023-10-25 10:00:02 +01:00
|
|
|
# Remove-Item
|
|
|
|
|
|
|
|
> Delete files, folders, as well as registry keys and subkeys.
|
|
|
|
> This command can only be run through PowerShell.
|
|
|
|
> More information: <https://learn.microsoft.com/powershell/module/microsoft.powershell.management/remove-item>.
|
|
|
|
|
|
|
|
- Remove specific files or registry keys (without subkeys):
|
|
|
|
|
2023-11-12 09:46:05 +00:00
|
|
|
`Remove-Item {{path\to\file_or_key1 , path\to\file_or_key2 ...}}`
|
2023-10-25 10:00:02 +01:00
|
|
|
|
|
|
|
- Remove hidden or read-only files:
|
|
|
|
|
2023-11-12 09:46:05 +00:00
|
|
|
`Remove-Item -Force {{path\to\file1 , path\to\file2 ...}}`
|
2023-10-25 10:00:02 +01:00
|
|
|
|
|
|
|
- Remove specific files or registry keys interactively prompting before each removal:
|
|
|
|
|
2023-11-12 09:46:05 +00:00
|
|
|
`Remove-Item -Confirm {{path\to\file_or_key1 , path\to\file_or_key2 ...}}`
|
2023-10-25 10:00:02 +01:00
|
|
|
|
|
|
|
- Remove specific files and directories recursively (Windows 10 version 1909 or later):
|
|
|
|
|
2023-11-12 09:46:05 +00:00
|
|
|
`Remove-Item -Recurse {{path\to\file_or_directory1 , path\to\file_or_directory2 ...}}`
|
2023-10-25 10:00:02 +01:00
|
|
|
|
|
|
|
- Remove specific Windows registry keys and all its subkeys:
|
|
|
|
|
2023-11-12 09:46:05 +00:00
|
|
|
`Remove-Item -Recurse {{path\to\key1 , path\to\key2 ...}}`
|
2023-10-25 10:00:02 +01:00
|
|
|
|
|
|
|
- Perform a dry run of the deletion process:
|
|
|
|
|
2023-11-12 09:46:05 +00:00
|
|
|
`Remove-Item -WhatIf {{path\to\file1 , path\to\file2 ...}}`
|