0
0
PowerShellscripting~20 mins

Why file management is core to scripting in PowerShell - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
File Management Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2: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
AOutputs the full path of all files in the current directory
BLists all files and folders in the current directory, including subdirectories
CShows an error because -Filter cannot be used with Get-ChildItem
DLists all filenames with .txt extension in the current directory, one per line
Attempts:
2 left
💡 Hint
Think about what -Filter and Select-Object do in this command.
🧠 Conceptual
intermediate
1:30remaining
Why is file management important in scripting?
Which of the following best explains why file management is a core skill in scripting?
ABecause scripts often need to read, write, or organize files to automate tasks
BBecause scripts only work with files and cannot interact with other system parts
CBecause file management is the only way to run scripts on a computer
DBecause scripts must always delete files to free up space
Attempts:
2 left
💡 Hint
Think about what tasks scripts automate in daily computer use.
🔧 Debug
advanced
2: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
AThe -Recurse parameter is invalid here because wildcards with -Path do not support recursion
BThe destination path must be enclosed in quotes
CThe script is missing a -Force parameter to overwrite files
DThe source path should use forward slashes instead of backslashes
Attempts:
2 left
💡 Hint
Check how wildcards and recursion work together in Copy-Item.
🚀 Application
advanced
2: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?
AGet-ChildItem -Filter *.txt | Rename-Item -NewName {"OLD_" + $_.Name}
BGet-ChildItem -Filter *.txt | Rename-Item -NewName {"OLD_" + $_.BaseName + $_.Extension}
CGet-ChildItem -Filter *.txt | Rename-Item -NewName {"OLD_" + $_}
DGet-ChildItem -Filter *.txt | Rename-Item -NewName {"OLD_" + $_.FullName}
Attempts:
2 left
💡 Hint
Consider how to build the new filename correctly including extension.
📝 Syntax
expert
2: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?
AIt throws a runtime error because New-Item requires -Force
BIt throws a syntax error due to missing semicolon
CIt runs successfully and creates the directory if missing
DIt fails because Test-Path cannot be negated with !
Attempts:
2 left
💡 Hint
Check if the syntax and commands are valid PowerShell.