Skip to content

Commit

Permalink
Add developer setting to disable -ExecutionPolicy Bypass flags
Browse files Browse the repository at this point in the history
  • Loading branch information
andyleejordan committed Jan 8, 2024
1 parent 18a8f83 commit bcd825b
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,11 @@
"default": false,
"markdownDescription": "Launches the LSP server with the `/waitForDebugger` flag to force it to wait for a .NET debugger to attach before proceeding, and emit its PID until then. **This setting is only meant for extension developers and requires the extension to be run in development mode!**"
},
"powershell.developer.setExecutionPolicy": {
"type": "boolean",
"default": true,
"markdownDescription": "On Windows we launch the PowerShell executable with `-ExecutionPolicy Bypass` so that the LSP server (PowerShell Editor Services module) will launch without issue. Some anti-virus programs disallow this command-line argument and this flag can be used to remove it. **Using this setting may require trusting the script manually in order for it to launch!**"
},
"powershell.developer.featureFlags": {
"type": "array",
"items": {
Expand Down
2 changes: 1 addition & 1 deletion src/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class PowerShellProcess {
powerShellArgs.push("-NoProfile");

// Only add ExecutionPolicy param on Windows
if (utils.isWindows) {
if (utils.isWindows && this.sessionSettings.developer.setExecutionPolicy) {
powerShellArgs.push("-ExecutionPolicy", "Bypass");
}

Expand Down
1 change: 1 addition & 0 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ export class SessionManager implements Middleware {
|| settings.developer.editorServicesLogLevel !== this.sessionSettings.developer.editorServicesLogLevel
|| settings.developer.bundledModulesPath !== this.sessionSettings.developer.bundledModulesPath
|| settings.developer.editorServicesWaitForDebugger !== this.sessionSettings.developer.editorServicesWaitForDebugger
|| settings.developer.setExecutionPolicy !== this.sessionSettings.developer.setExecutionPolicy
|| settings.integratedConsole.useLegacyReadLine !== this.sessionSettings.integratedConsole.useLegacyReadLine
|| settings.integratedConsole.startInBackground !== this.sessionSettings.integratedConsole.startInBackground
|| settings.integratedConsole.startLocation !== this.sessionSettings.integratedConsole.startLocation)) {
Expand Down
1 change: 1 addition & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class DeveloperSettings extends PartialSettings {
bundledModulesPath = "../../PowerShellEditorServices/module";
editorServicesLogLevel = LogLevel.Normal;
editorServicesWaitForDebugger = false;
setExecutionPolicy = true;
waitForSessionFileTimeoutSeconds = 240;
}

Expand Down

0 comments on commit bcd825b

Please sign in to comment.