Bird
0
0

What will be the output of this PowerShell command?

medium📝 Command Output Q13 of 15
PowerShell - File and Directory Operations
What will be the output of this PowerShell command?
Get-ChildItem -Path . -Filter '*.txt' | Select-Object -ExpandProperty Name
ALists all file names with .txt extension in the current directory
BLists all folders in the current directory
CShows full file paths of all files
DDeletes all .txt files in the current directory
Step-by-Step Solution
Solution:
  1. Step 1: Understand the command parts

    Get-ChildItem with -Filter '*.txt' selects files ending with .txt. Select-Object -ExpandProperty Name extracts just the file names.
  2. Step 2: Determine the output

    The command outputs a list of .txt file names in the current directory, not folders or full paths, and does not delete files.
  3. Final Answer:

    Lists all file names with .txt extension in the current directory -> Option A
  4. Quick Check:

    Filter '*.txt' + expand Name = list of .txt file names [OK]
Quick Trick: Filter '*.txt' lists text files; expand Name shows just names [OK]
Common Mistakes:
  • Thinking it lists folders instead of files
  • Assuming it shows full file paths
  • Confusing it with a delete command

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes