File tree 1 file changed +9
-0
lines changed
src/PowerShellEditorServices/Services/Analysis
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 10
10
using System . Threading . Tasks ;
11
11
using Microsoft . Extensions . Logging ;
12
12
using Microsoft . PowerShell . EditorServices . Services . TextDocument ;
13
+ using Microsoft . PowerShell . EditorServices . Utility ;
13
14
14
15
namespace Microsoft . PowerShell . EditorServices . Services . Analysis
15
16
{
@@ -360,6 +361,14 @@ private static RunspacePool CreatePssaRunspacePool(string pssaModulePath)
360
361
// We intentionally use `CreateDefault2()` as it loads `Microsoft.PowerShell.Core`
361
362
// only, which is a more minimal and therefore safer state.
362
363
InitialSessionState sessionState = InitialSessionState . CreateDefault2 ( ) ;
364
+
365
+ // We set the runspace's execution policy `Bypass` so we can always import our bundled
366
+ // PSScriptAnalyzer module.
367
+ if ( VersionUtils . IsWindows )
368
+ {
369
+ sessionState . ExecutionPolicy = ExecutionPolicy . Bypass ;
370
+ }
371
+
363
372
sessionState . ImportPSModulesFromPath ( pssaModulePath ) ;
364
373
365
374
RunspacePool runspacePool = RunspaceFactory . CreateRunspacePool ( sessionState ) ;
You can’t perform that action at this time.
0 commit comments