diff --git a/src/System.Management.Automation/security/wldpNativeMethods.cs b/src/System.Management.Automation/security/wldpNativeMethods.cs index 730db922a00..a2be725da73 100644 --- a/src/System.Management.Automation/security/wldpNativeMethods.cs +++ b/src/System.Management.Automation/security/wldpNativeMethods.cs @@ -110,9 +110,9 @@ public static SystemScriptFileEnforcement GetFilePolicyEnforcement( { SafeHandle fileHandle = fileStream.SafeFileHandle; - // First check latest WDAC APIs if available. + // First check latest WDAC APIs if available. Also revert to legacy APIs if debug hook is in effect. Exception errorException = null; - if (s_wldpCanExecuteAvailable) + if (s_wldpCanExecuteAvailable && !s_allowDebugOverridePolicy) { try {