Bird
0
0

What output will this PowerShell Core script produce when run on macOS?

medium📝 Command Output Q4 of 15
PowerShell - Cross-Platform PowerShell
What output will this PowerShell Core script produce when run on macOS?
if ($PSVersionTable.Platform -eq 'Unix') { 'Running cross-platform' } else { 'Running Windows only' }
ARunning cross-platform
BRunning Windows only
CNo output
DError due to unsupported platform
Step-by-Step Solution
Solution:
  1. Step 1: Understand $PSVersionTable.Platform on macOS

    On macOS, this property returns 'Unix'.
  2. Step 2: Evaluate the if condition

    Since it equals 'Unix', the first branch runs.
  3. Final Answer:

    Running cross-platform -> Option A
  4. Quick Check:

    macOS is detected as 'Unix' platform [OK]
Quick Trick: macOS platform equals 'Unix' in PowerShell Core [OK]
Common Mistakes:
  • Assuming macOS returns 'macOS' instead of 'Unix'
  • Expecting Windows output on macOS
  • Thinking script errors on macOS

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes