I am using PowerShell ISE (PS version 5.0). If I run this code:
Write-Host "This"
It outputs:
This
If I change the script as follows:
Write-Host "That"
It outputs:
That
Great. As expected. Now, if I have this code:
$Form = New-Object System.Windows.Forms.Form $Timer = New-Object System.Windows.Forms.Timer $Timer.Add_Tick( { &{ Write-Output "Here" $Form.Close()} | Write-Host }) $Timer.Interval = 3000 $Timer.start() $result = $Form.ShowDialog()
It outputs:
Here
If I changed something in a script, for example. "Here" to "There" or $Timer.Interval = 3000 to $Timer.Interval = 4000 and run it, it will do two unexpected things: 1.) instead of showing the form for the proper length of time, it blinks briefly on screen, and 2.) instead of There displays the original Here . If I close ISE and open it again, the script will work as expected.
What's happening?
source share