{"id":"KB-PS5-1-INLINE-IF-FMT","note":"Observed with: Write-Host (\"...{0}\" -f (if($cond){\"X\"} else {\"Y\"})). In PS 5.1 the token \"if\" can be parsed as a command when used raw inside the format argument.","blocking":false,"fix":"Refactor: $val = if($cond){\"X\"} else {\"Y\"}; (\"...{0}\" -f $val).","tags":["powershell","format","compat","ps5.1"],"workaround":"Precompute value in a variable or use sub-expression $() before -f; avoid inline if inside the format argument.","seen_in_threads":"2025-10-22","title":"Inline \"if\" inside -f format causes CommandNotFoundException in PS 5.1","last_seen":""}