Skip to content

Script Analysis unavailable when execution policy does not trust PSScriptAnalyzer #2507

Open
@rjmholt

Description

@rjmholt

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions