Cif ($PSVersionTable.Platform -eq 'Unix') { Write-Host 'Linux or macOS' }
Dif ($Platform -eq 'Unix') { Write-Host 'Unix' }
Step-by-Step Solution
Solution:
Step 1: Identify correct property for OS platform
$PSVersionTable.Platform is the standard way to check OS platform in PowerShell Core.
Step 2: Check syntax correctness
if ($PSVersionTable.Platform -eq 'Unix') { Write-Host 'Linux or macOS' } uses correct syntax and property. Others use invalid or non-existent properties.
Final Answer:
if ($PSVersionTable.Platform -eq 'Unix') { Write-Host 'Linux or macOS' } -> Option C
Quick Check:
Use $PSVersionTable.Platform for OS check [OK]
Quick Trick:Use $PSVersionTable.Platform to detect OS [OK]
Common Mistakes:
Using $env:OS which is Windows-only
Referencing non-existent $PSVersionTable.OS
Using undefined variable $Platform
Master "Cross-Platform PowerShell" in PowerShell
9 interactive learning modes - each teaches the same concept differently