>>872-873
まあバグ(MS的には仕様とも言う)みたいなもんやね

Until PowerShell 7, containing a statement within parentheses (...), subexpression syntax $(...) or array expression @(...) always reset $? to True , so that (Write-Error) shows $? as True.
This has been changed in PowerShell 7, so that $? will always reflect the actual success of the last command run in these expressions.

https://docs.microsoft.com/ja-jp/powershell/module/microsoft.powershell.core/about/about_automatic_variables?view=powershell-7.1#short-description

なのでPowerShellを7にすれば解決するかと