Bird
0
0

What will this PowerShell Core script output on a Linux system?

medium📝 Command Output Q13 of 15
PowerShell - Cross-Platform PowerShell
What will this PowerShell Core script output on a Linux system?
if ($PSVersionTable.Platform -eq 'Unix') { 'Cross-platform script running' } else { 'Windows script running' }
ACross-platform script running
BWindows script running
CError: Property not found
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand $PSVersionTable.Platform on Linux

    On Linux, $PSVersionTable.Platform equals 'Unix'.
  2. Step 2: Evaluate the if condition

    The condition is true, so the script outputs 'Cross-platform script running'.
  3. Final Answer:

    Cross-platform script running -> Option A
  4. Quick Check:

    Linux means Platform='Unix' => Output A [OK]
Quick Trick: On Linux, Platform is 'Unix' so if condition is true [OK]
Common Mistakes:
  • Assuming Platform is 'Linux' instead of 'Unix'
  • Expecting Windows output on Linux
  • Thinking script throws error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes