我想用posh腳本自動打開ISE中的最後一個opend文件,因此我嘗試保存這些文件的文件路徑,如下所示。如何打開ISE中最後打開的文件的起始
$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
,exitingtest.log創建,並已 「現在退出...」, 但不創建psISElastOpenedFiles.txt。 ISE似乎在執行退出事件之前關閉所有打開的文件。
我應該使用Timer事件嗎?