Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add developer setting to disable -ExecutionPolicy Bypass flags #4883

Merged
merged 1 commit into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
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
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
Loading