Last Updated: February 25, 2016
· cerebrate

Don't write-host in the Powershell.Exited event

...if you ever use the PowerShell ISE.

There's an undocumented bug in ISE whereby the tab hosting PowerShell shuts down before PowerShell itself has finished exiting. Consequently, if you include any write-host statements or other cmdlets that output to the host in your Register-EngineEvent PowerShell.Exited scriptblocks, they'll fail to execute, and they'll even stop other registered scriptblocks for this event from executing, also.

Say Thanks