0
0
PowerShellscripting~5 mins

Remove-Item in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PowerShell cmdlet <code>Remove-Item</code> do?
It deletes files, folders, or other items from a specified location.
Click to reveal answer
beginner
How do you remove a file named example.txt using Remove-Item?
Use the command: <br>Remove-Item example.txt
Click to reveal answer
intermediate
What parameter do you use with Remove-Item to delete a folder and all its contents?
Use the -Recurse parameter to delete a folder and everything inside it.
Click to reveal answer
intermediate
How can you force deletion of a read-only file with Remove-Item?
Add the -Force parameter to override restrictions and delete the file.
Click to reveal answer
beginner
What happens if you try to remove a file that does not exist using Remove-Item without any error handling?
PowerShell will show an error saying the file was not found.
Click to reveal answer
Which parameter deletes all files and subfolders inside a folder with Remove-Item?
A-Recurse
B-Force
C-Path
D-Include
What does the -Force parameter do in Remove-Item?
ADeletes hidden or read-only files
BDeletes only empty folders
CPrompts before deleting
DCopies files instead of deleting
How do you delete a single file named data.csv using Remove-Item?
ARemove-Item -Force
BRemove-Item -Recurse data.csv
CRemove-Item data.csv
DRemove-Item -Include data.csv
What happens if you run Remove-Item on a folder without -Recurse and the folder is not empty?
AThe folder and contents are deleted
BThe folder is renamed
COnly files inside are deleted
DPowerShell shows an error and does not delete
Which command deletes all .log files in the current folder?
ARemove-Item -Recurse *.log
BRemove-Item *.log
CRemove-Item -Force *.txt
DRemove-Item -Include *.log
Explain how to safely delete a folder and all its contents using PowerShell's Remove-Item.
Think about deleting folders with files inside and how to override restrictions.
You got /4 concepts.
    Describe what happens if you try to remove a file that does not exist using Remove-Item without error handling.
    Consider what PowerShell does when the target is missing.
    You got /3 concepts.