Bird
0
0

Find the mistake in this command:

medium📝 Debug Q7 of 15
PowerShell - File and Directory Operations
Find the mistake in this command:
New-Item -Path 'C:\Projects\' -ItemType Directory -Name 'NewFolder'
ATrailing backslash in -Path causes error
BMissing -Force parameter
CCannot use -Name with -Path ending with backslash
DCorrect syntax, no mistake
Step-by-Step Solution
Solution:
  1. Step 1: Understand -Path and -Name usage

    When using -Name, -Path should specify the directory without trailing backslash to avoid confusion.
  2. Step 2: Analyze the command

    Here, -Path ends with '\' and -Name is used, which can cause issues in some PowerShell versions.
  3. Final Answer:

    Cannot use -Name with -Path ending with backslash -> Option C
  4. Quick Check:

    Remove trailing backslash when using -Name [OK]
Quick Trick: Avoid trailing backslash in -Path when using -Name [OK]
Common Mistakes:
  • Leaving trailing backslash with -Name
  • Assuming -Force is mandatory
  • Confusing directory and file creation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes