This project is read-only.

Sending remote Extrating events crashes powershell

Nov 23, 2011 at 2:04 PM
Edited Nov 23, 2011 at 2:12 PM

Add-Type -Path 'F:\7zDLLs\SevenZipSharp.dll' #Presumably needed so the main session can grok the 7z events.

Start-Job -InitializationScript { #Needed because sessions don't share modules
  Add-Type -Path 'F:\7zDLLs\SevenZipSharp.dll'
} -ScriptBlock {
  $extractor = New-Object SevenZip.SevenZipExtractor('D:\prep.7z')
  Register-ObjectEvent -InputObject $extractor -EventName Extracting -Forward
  Write-Host $extractor
  Write-Host 'Finished!'

Without the Register-ObjectEvent this works fine. But it crashes powershell with it. I tried this background job variant as an alternative for simple foreground job plus -Action scriptblock, which doesn't crash, but doesn't generate events except after the extraction is all finished. The whole powershell events stuff is a big M$ snafu.