hi all, i wanted to automatically open the last opend files in ISE with posh script, so i tryed to save filepaths of these files like the following.
$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 exiting...", but psISElastOpenedFiles.txt isn't created. it seems that ISE closes all opening files before the exiting event is executed.
should i use Timer event?