Code execution $? = $true $? = $true in powershell crashes the program with the Windows error message "Operating system shutdown message".
Some built-in functions, such as $true or $host , cause an error: Cannot overwrite variable true because it is read-only or constant. . Others, such as $myinvocation or $null , are simply ignored. Why $? is different? Is there any documentation on which the inline ones have an answer? help about_automatic_variables does not contain any details.
I am currently running version 5.1. I also tried using powershell -version $n '$? = $true' powershell -version $n '$? = $true' and version 3-5 all crashes. Interestingly, versions 1 and 2 do not; they cause a read-only variable error.
source share