I wanted to automatically open the latest opend files in ISE using the posh script, so I tried to save the file paths of these files as follows.
$action = {
$psISE.CurrentPowerShellTab.Files | select -ExpandProperty FullPath | ? { Test-Path $_ } |
Set-Content -Encoding String -Path$PSHOME\psISElastOpenedFiles.txt
Set-Content -Encoding String -Value "Now exiting..." -Path c:\exitingtest.log
}
Register-EngineEvent -SourceIdentifier Exit -SupportEvent -Action $action
When I close ISE, exitingtest.log is created and has "Now exit ...", but psISElastOpenedFiles.txt is not created. it seems that ISE closes all opening files before the output event is executed.
Should I use the Timer event?
source
share