Open
Description
Due to how we lazily load PSScriptAnalyzer, script analysis currently does not work when execution policy is set in a way that prevents loading of PSScriptAnalyzer. This can occur even in environments where we have managed to start in Bypass
mode, because we set it back to the correct execution policy before PSSA is loaded.
User workarounds are:
- Use a less restrictive execution policy
- Trust the PSScriptAnalyzer module
Our possible workarounds are:
- Load PSScriptAnalyzer earlier (this does not solve scenarios where execution policy is set by GPO)
- Somehow trust PSScriptAnalyzer in code
The best solution is for us to pull in PSScriptAnalyzer as a .NET dependency instead of loading it as a PowerShell module.