Bird
0
0

You want to list all hidden files and folders in D:\Work including subfolders. Which command is correct?

hard📝 Application Q9 of 15
PowerShell - File and Directory Operations
You want to list all hidden files and folders in D:\Work including subfolders. Which command is correct?
AGet-ChildItem -Path D:\Work -Recurse | Where-Object { $_.Attributes -match 'Hidden' }
BGet-ChildItem -Path D:\Work -Recurse -Hidden
CGet-ChildItem -Path D:\Work -Hidden -File
DGet-ChildItem -Path D:\Work -Recurse -Attributes Hidden
Step-by-Step Solution
Solution:
  1. Step 1: Understand -Hidden parameter limitation

    Get-ChildItem does not have a native -Hidden parameter; filtering must be done with Where-Object.
  2. Step 2: Use Where-Object to filter hidden items

    Get-ChildItem -Path D:\Work -Recurse | Where-Object { $_.Attributes -match 'Hidden' } correctly filters items whose Attributes include 'Hidden'.
  3. Step 3: Verify other options

    Options B and D use invalid parameters; C misses recursion.
  4. Final Answer:

    Get-ChildItem -Path D:\Work -Recurse | Where-Object { $_.Attributes -match 'Hidden' } -> Option A
  5. Quick Check:

    Filter hidden with Where-Object = Get-ChildItem -Path D:\Work -Recurse | Where-Object { $_.Attributes -match 'Hidden' } [OK]
Quick Trick: Filter hidden files using Where-Object and Attributes property [OK]
Common Mistakes:
  • Using non-existent -Hidden parameter
  • Not using -Recurse to include subfolders
  • Filtering only files or only folders

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes