Bird
0
0

Which of the following is the correct syntax to check if a directory C:\Data exists using Test-Path?

easy📝 Syntax Q3 of 15
PowerShell - File and Directory Operations
Which of the following is the correct syntax to check if a directory C:\Data exists using Test-Path?
ATest-Path -Directory 'C:\Data'
BTest-Path -IsDirectory 'C:\Data'
CTest-Path 'C:\Data'
DTest-Path -Folder 'C:\Data'
Step-by-Step Solution
Solution:
  1. Step 1: Understand Test-Path parameters

    Test-Path does not have -Directory, -IsDirectory, or -Folder parameters.
  2. Step 2: Use correct syntax

    Simply passing the path string checks if the directory exists.
  3. Final Answer:

    Test-Path 'C:\Data' -> Option C
  4. Quick Check:

    Test-Path path only = Test-Path 'C:\Data' [OK]
Quick Trick: Test-Path needs only the path string to check existence [OK]
Common Mistakes:
  • Using non-existent parameters like -Directory
  • Confusing Test-Path with other cmdlets

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes