Challenge - 5 Problems
Get-ChildItem 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 Get-ChildItem command?
You run this command in a folder containing three files: file1.txt, file2.log, and file3.txt.
What will be listed?
Get-ChildItem -Filter *.txtWhat will be listed?
PowerShell
Get-ChildItem -Filter *.txt
Attempts:
2 left
💡 Hint
Think about what the filter *.txt means.
✗ Incorrect
The -Filter parameter limits the output to files matching the pattern. Here, only files ending with .txt are shown.
💻 Command Output
intermediate2:00remaining
What does this command output?
You run this command in a folder with subfolders and files:
What will it list?
Get-ChildItem -Recurse -DirectoryWhat will it list?
PowerShell
Get-ChildItem -Recurse -Directory
Attempts:
2 left
💡 Hint
Look at the -Directory switch.
✗ Incorrect
The -Directory switch limits output to folders only. Combined with -Recurse, it lists all folders inside the current folder and its subfolders.
📝 Syntax
advanced2:00remaining
Which command correctly lists all hidden files in the current folder?
Choose the correct PowerShell command to list hidden files only.
Attempts:
2 left
💡 Hint
Check how to filter by attributes in Get-ChildItem.
✗ Incorrect
The -Attributes parameter filters by file attributes. Using -Attributes Hidden lists only hidden files.
🔧 Debug
advanced2:00remaining
Why does this command fail to list files larger than 1MB?
You try to list files larger than 1MB with:
But it returns no files. Why?
Get-ChildItem | Where-Object { $_.Length -gt 1MB }But it returns no files. Why?
PowerShell
Get-ChildItem | Where-Object { $_.Length -gt 1MB }Attempts:
2 left
💡 Hint
Check how to specify file size in bytes.
✗ Incorrect
PowerShell does not understand '1MB' as a number. You must use bytes, e.g., 1MB = 1*1024*1024 = 1048576.
🚀 Application
expert2:00remaining
How to list only files modified in the last 7 days?
You want to list files changed in the last 7 days using Get-ChildItem and Where-Object. Which command does this correctly?
Attempts:
2 left
💡 Hint
Think about comparing LastWriteTime to 7 days ago.
✗ Incorrect
Files modified in the last 7 days have LastWriteTime greater than the date 7 days ago.