Bird
0
0

Which PowerShell command temporarily appends C:\Scripts to the PATH environment variable for the current session only?

hard📝 Application Q8 of 15
PowerShell - System Administration
Which PowerShell command temporarily appends C:\Scripts to the PATH environment variable for the current session only?
A$env:PATH += ";C:\Scripts"
BSet-Item -Path Env:PATH -Value "C:\Scripts"
CAdd-Content Env:PATH "C:\Scripts"
DNew-Item Env:PATH -Value "C:\Scripts"
Step-by-Step Solution
Solution:
  1. Step 1: Understand environment variable modification

    To temporarily add a folder to PATH, append it to the existing PATH string.
  2. Step 2: Use the += operator with $env:PATH

    Appending ";C:\Scripts" to $env:PATH modifies the PATH for the current session only.
  3. Final Answer:

    $env:PATH += ";C:\Scripts" -> Option A
  4. Quick Check:

    Run Write-Output $env:PATH to verify the new path is appended [OK]
Quick Trick: Append with $env:PATH += ";NewFolder" for session-only PATH changes [OK]
Common Mistakes:
  • Overwriting PATH instead of appending
  • Using Set-Item without preserving existing PATH
  • Using Add-Content or New-Item which are invalid for env vars

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes