I am playing with PowerShell and I have encountered a crash that I can easily reproduce on my computer.
I am not sure if the code is correct. However, when the next fragment starts, it crashes powershell.exeand powershell_ise.exe. I assume that my use if ( $? = $false )is incorrect, but in this case, an accident should not occur. Removing an instruction Ifhelps to avoid a failure.
Is there anything I don't see?
I am running Windows 10 Pro and PowerShell 5.1.14393.206.
Update 1
OK, thanks @Martin. I know that I mistakenly used =instead -eq. But why is this happening?
Update 2
Filed an error in PowerShell UserVoice: https://windowsserver.uservoice.com/forums/301869-powershell/suggestions/16977433-assigning-a-value-to-false-crashes
Update 3
This seems to be a known bug: https://github.com/PowerShell/PowerShell/issues/2243 , which should be fixed soon https://github.com/PowerShell/PowerShell/pull/2320
Test-Path "C:\test"
if ( $? = $false ) {
Out-Host "Hello World"
}
Fault bucket 127386360339, type 5
Event Name: PowerShell
Response: Not available
Cab Id: 0
Problem signature:
P1: powershell.exe
P2: 10.0.14393.206
P3: stem.Management.Automation.PSInvalidCast
P4: stem.Management.Automation.PSInvalidCast
P5: ation.LanguagePrimitives.ThrowInvalidCastException
P6: ation.LanguagePrimitives.ThrowInvalidCastException
P7: Pipeli..ution Thread
P8:
P9:
P10:
source
share