Bird
0
0

What will this PowerShell command output?

medium📝 Command Output Q5 of 15
PowerShell - System Administration
What will this PowerShell command output?
Write-Output $env:NON_EXISTENT_VAR
AError: Variable not found
BEmpty string
CNON_EXISTENT_VAR
DNull
Step-by-Step Solution
Solution:
  1. Step 1: Check behavior for unset environment variables

    Accessing a non-existent environment variable returns an empty string, not an error.
  2. Step 2: Confirm output of Write-Output

    Write-Output prints the empty string, resulting in no visible output.
  3. Final Answer:

    Empty string -> Option B
  4. Quick Check:

    Unset env var output = B [OK]
Quick Trick: Unset env vars return empty string, not error [OK]
Common Mistakes:
  • Expecting error on missing variable
  • Printing variable name instead of value
  • Confusing null with empty string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes