internal/scripts/removalEvent.ps1

1
2
3
4
5
6
7
#region Handle Module Removal
$PSF_OnRemoveScript = {
    Get-PSFRunspace | Stop-PSFRunspace
}
$ExecutionContext.SessionState.Module.OnRemove += $PSF_OnRemoveScript
Register-EngineEvent -SourceIdentifier ([System.Management.Automation.PsEngineEvent]::Exiting) -Action $PSF_OnRemoveScript
#endregion Handle Module Removal