diff --git a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs index ab4e1067ac..78d459933f 100644 --- a/src/System.Management.Automation/engine/runtime/Binding/Binders.cs +++ b/src/System.Management.Automation/engine/runtime/Binding/Binders.cs @@ -6947,7 +6947,7 @@ internal static DynamicMetaObject InvokeDotNetMethod( // - Log method invocation to AMSI Notifications (can throw PSSecurityException) // - Invoke method string targetName = methodInfo.ReflectedType?.FullName ?? string.Empty; - MaybeAddMemberInvocationLogging(expr, targetName, name, args); + expr = MaybeAddMemberInvocationLogging(expr, targetName, name, args); // If we're calling SteppablePipeline.{Begin|Process|End}, we don't want // to wrap exceptions - this is very much a special case to help error