Challenge - 5 Problems
File Management Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell command?
Consider the following command that lists files in a directory and filters by extension. What output will it produce?
PowerShell
Get-ChildItem -Path . -Filter *.txt | Select-Object -ExpandProperty Name
Attempts:
2 left
💡 Hint
Think about what -Filter and Select-Object do in this command.
✗ Incorrect
Get-ChildItem with -Filter *.txt lists only files ending with .txt. Select-Object -ExpandProperty Name extracts just the filenames, not full paths or folders.
🧠 Conceptual
intermediate1:30remaining
Why is file management important in scripting?
Which of the following best explains why file management is a core skill in scripting?
Attempts:
2 left
💡 Hint
Think about what tasks scripts automate in daily computer use.
✗ Incorrect
Scripts automate many tasks involving files like backups, data processing, or organizing. Managing files is essential to these tasks.
🔧 Debug
advanced2:30remaining
Identify the error in this PowerShell script snippet
This script tries to copy all .log files from one folder to another but fails. What is the error?
PowerShell
Copy-Item -Path C:\Logs\*.log -Destination C:\BackupLogs -Recurse
Attempts:
2 left
💡 Hint
Check how wildcards and recursion work together in Copy-Item.
✗ Incorrect
Using wildcards with -Path disables recursion. To recurse, you must specify the folder path without wildcards and use -Filter instead.
🚀 Application
advanced2:30remaining
Which script snippet correctly renames all .txt files by adding a prefix?
You want to add the prefix 'OLD_' to all .txt files in a folder. Which snippet does this correctly?
Attempts:
2 left
💡 Hint
Consider how to build the new filename correctly including extension.
✗ Incorrect
Option B correctly concatenates 'OLD_' with the base filename and the extension. Option B tries to add prefix to full name which can cause errors. Options C and D use wrong properties.
📝 Syntax
expert2:00remaining
What error does this PowerShell script produce?
Analyze this script that attempts to create a directory if it doesn't exist:
if (!(Test-Path -Path C:\Data)) {
New-Item -ItemType Directory -Path C:\Data
}
What happens when you run it?
Attempts:
2 left
💡 Hint
Check if the syntax and commands are valid PowerShell.
✗ Incorrect
The script uses valid syntax. ! negates the boolean result of Test-Path. New-Item creates the directory if it doesn't exist. No errors occur.