Bird
0
0

Which of the following is the correct syntax to list only directories in the current folder using Get-ChildItem?

easy📝 Syntax Q3 of 15
PowerShell - File and Directory Operations
Which of the following is the correct syntax to list only directories in the current folder using Get-ChildItem?
AGet-ChildItem -Directory
BGet-ChildItem -OnlyDirectories
CGet-ChildItem -Folders
DGet-ChildItem -File
Step-by-Step Solution
Solution:
  1. Step 1: Identify the parameter for directories

    The correct parameter to list only directories is -Directory.
  2. Step 2: Check other options for correctness

    -File lists files, -Folders and -OnlyDirectories are invalid parameters.
  3. Final Answer:

    Get-ChildItem -Directory -> Option A
  4. Quick Check:

    List directories = -Directory [OK]
Quick Trick: Use -Directory to list only folders [OK]
Common Mistakes:
  • Using -File to list folders
  • Using non-existent parameters like -Folders
  • Confusing parameter names

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes