Bird
0
0

What will be the output of this PowerShell code?

medium📝 Command Output Q4 of 15
PowerShell - System Administration
What will be the output of this PowerShell code?
$env:TEST_VAR = 'PowerShell'
Write-Output $env:TEST_VAR
ATEST_VAR
B$env:TEST_VAR
CPowerShell
DError: Variable not found
Step-by-Step Solution
Solution:
  1. Step 1: Assign value to environment variable

    The code sets $env:TEST_VAR to the string 'PowerShell'.
  2. Step 2: Output the variable's value

    Write-Output $env:TEST_VAR prints the value stored, which is 'PowerShell'.
  3. Final Answer:

    PowerShell -> Option C
  4. Quick Check:

    Output of $env:TEST_VAR = C [OK]
Quick Trick: Write-Output prints the value of $env: variables [OK]
Common Mistakes:
  • Printing variable name instead of value
  • Expecting error on valid variable
  • Confusing syntax for output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes