Steps to reproduce
Register-EngineEvent -SourceIdentifier Powershell.Exiting -Action { Set-Content -Value "Hello there." -Path "$env:TEMP\General Kenobi.txt" }
exit
Instead of exit, the user may also close the Powershell with the x-Button.
Expected behavior
I expect that Powershell executes every command in the -Action parameter before it exits. In this case, I expected that a file General Kenobi.txt would have been written to $env:TEMP.
Actual behavior
Powershell does not execute the action in any case. Not when exiting via exit command and not when exiting by pressing the x-button of the powershell console window.
This not only happens in PS6 but also in PS5.
Environment data
> $PSVersionTable
Name Value
---- -----
PSVersion 6.1.0
PSEdition Core
GitCommitId 6.1.0
OS Microsoft Windows 10.0.17763
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Steps to reproduce
Instead of exit, the user may also close the Powershell with the x-Button.
Expected behavior
I expect that Powershell executes every command in the
-Actionparameter before it exits. In this case, I expected that a fileGeneral Kenobi.txtwould have been written to$env:TEMP.Actual behavior
Powershell does not execute the action in any case. Not when exiting via
exitcommand and not when exiting by pressing the x-button of the powershell console window.This not only happens in PS6 but also in PS5.
Environment data