Challenge - 5 Problems
PowerShell Remove-Item Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this Remove-Item command?
Consider a folder named 'TestFolder' containing files 'a.txt' and 'b.txt'. What happens after running this command?
Remove-Item -Path 'TestFolder\a.txt'
PowerShell
Remove-Item -Path 'TestFolder\a.txt'Attempts:
2 left
💡 Hint
Remove-Item deletes the specified file or folder, not siblings unless specified.
✗ Incorrect
Remove-Item with a file path deletes only that file. It does not affect other files in the folder.
💻 Command Output
intermediate2:00remaining
What error does this Remove-Item command raise?
What error occurs when running this command if 'NonExistentFile.txt' does not exist?
Remove-Item -Path 'NonExistentFile.txt'
PowerShell
Remove-Item -Path 'NonExistentFile.txt'Attempts:
2 left
💡 Hint
By default, Remove-Item throws an error if the path is missing.
✗ Incorrect
Remove-Item throws a terminating error if the specified path does not exist unless -ErrorAction is used.
📝 Syntax
advanced2:00remaining
Which Remove-Item command correctly deletes all files in a folder but keeps the folder?
You want to delete all files inside 'Logs' folder but keep the folder itself. Which command does this correctly?
Attempts:
2 left
💡 Hint
Use wildcard to target contents, not folder itself.
✗ Incorrect
Using 'Logs\*' targets all contents inside 'Logs' folder. -Recurse deletes files and subfolders inside, but not the folder itself.
🚀 Application
advanced2:00remaining
How to safely delete a folder and all its contents without prompt?
You want to delete 'OldData' folder and everything inside it without any confirmation prompts. Which command achieves this?
Attempts:
2 left
💡 Hint
Use parameters to suppress prompts and delete recursively.
✗ Incorrect
-Recurse deletes all contents including subfolders. -Force suppresses prompts and deletes read-only files.
🧠 Conceptual
expert2:00remaining
What is the effect of running Remove-Item with -WhatIf parameter?
You run:
What happens?
Remove-Item -Path 'Data\*' -Recurse -WhatIf
What happens?
Attempts:
2 left
💡 Hint
-WhatIf is a safety feature to preview actions.
✗ Incorrect
-WhatIf simulates the command and shows what would happen without making changes.