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.txtClick 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?✗ Incorrect
The
-Recurse parameter tells PowerShell to delete all contents inside the folder recursively.What does the
-Force parameter do in Remove-Item?✗ Incorrect
The
-Force parameter allows deletion of hidden or read-only files that normally cannot be deleted.How do you delete a single file named
data.csv using Remove-Item?✗ Incorrect
Simply specify the file name as the path:
Remove-Item data.csv.What happens if you run
Remove-Item on a folder without -Recurse and the folder is not empty?✗ Incorrect
Without
-Recurse, PowerShell will not delete a non-empty folder and will show an error.Which command deletes all
.log files in the current folder?✗ Incorrect
Using a wildcard
*.log deletes all files ending with .log in the current folder.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.