Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/System.Management.Automation/security/SecurityManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,6 @@ private bool CheckPolicy(ExternalScriptInfo script, PSHost host, out Exception r
// Get the execution policy
_executionPolicy = SecuritySupport.GetExecutionPolicy(_shellId);

// See if they want to bypass the authorization manager
if (_executionPolicy == ExecutionPolicy.Bypass)
return true;

// Always check the SAFER APIs if code integrity isn't being handled system-wide through
// WLDP or AppLocker. In those cases, the scripts will be run in ConstrainedLanguage.
// Otherwise, block.
Expand Down Expand Up @@ -184,6 +180,13 @@ private bool CheckPolicy(ExternalScriptInfo script, PSHost host, out Exception r
}
}

// WLDP and Applocker takes priority over powershell exeuction policy.
// See if they want to bypass the authorization manager
if (_executionPolicy == ExecutionPolicy.Bypass)
{
return true;
}

if (_executionPolicy == ExecutionPolicy.Unrestricted)
{
// Product binaries are always trusted
Expand Down