Bird
0
0

What will this script output on Windows PowerShell (not Core)?

medium📝 Command Output Q5 of 15
PowerShell - Cross-Platform PowerShell
What will this script output on Windows PowerShell (not Core)?
if ($PSVersionTable.Platform -eq 'Windows') { 'Windows PowerShell' } else { 'Other PowerShell' }
AWindows PowerShell
BOther PowerShell
CError: Platform property missing
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Check $PSVersionTable.Platform availability in Windows PowerShell

    Windows PowerShell does not have the Platform property in $PSVersionTable.
  2. Step 2: Result of accessing missing property

    Accessing it causes an error or returns null, so the condition fails and may cause an error.
  3. Final Answer:

    Error: Platform property missing -> Option C
  4. Quick Check:

    Platform property missing in Windows PowerShell = B [OK]
Quick Trick: Windows PowerShell lacks $PSVersionTable.Platform property [OK]
Common Mistakes:
  • Assuming Platform property exists in Windows PowerShell
  • Expecting 'Windows PowerShell' output
  • Ignoring possible errors from missing property

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes