From b83b9b474a120328fd96d86a14b4883e018a2443 Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 21 Mar 2018 09:28:22 -0700 Subject: [PATCH 1/2] Use 'Unregister-Event' to remove an event subscriber --- .../engine/hostifaces/HostUtilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs b/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs index 5fe16acd369..d1d892babe2 100644 --- a/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs +++ b/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs @@ -960,7 +960,7 @@ public static Collection InvokeOnRunspace(PSCommand command, Runspace Remove-Item -Path 'function:\global:PSEdit' -Force } - Get-EventSubscriber -SourceIdentifier PSISERemoteSessionOpenFile -EA Ignore | Remove-Event + Get-EventSubscriber -SourceIdentifier PSISERemoteSessionOpenFile -EA Ignore | Unregister-Event "; /// From 178070b8eb43f9445d2d4deb3d96d13c86f7488e Mon Sep 17 00:00:00 2001 From: Dongbo Wang Date: Wed, 21 Mar 2018 14:23:07 -0700 Subject: [PATCH 2/2] Address Aditya's feedback --- .../engine/hostifaces/HostUtilities.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs b/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs index d1d892babe2..5421a6284c3 100644 --- a/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs +++ b/src/System.Management.Automation/engine/hostifaces/HostUtilities.cs @@ -960,7 +960,7 @@ public static Collection InvokeOnRunspace(PSCommand command, Runspace Remove-Item -Path 'function:\global:PSEdit' -Force } - Get-EventSubscriber -SourceIdentifier PSISERemoteSessionOpenFile -EA Ignore | Unregister-Event + Unregister-Event -SourceIdentifier PSISERemoteSessionOpenFile -ErrorAction Ignore "; ///