Skip to content

Fix startup in AllSigned execution policy #1214

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

Merged
merged 3 commits into from
Feb 28, 2020

Conversation

rjmholt
Copy link
Contributor

@rjmholt rjmholt commented Feb 28, 2020

Fixes PowerShell/vscode-powershell#2504.

We were setting the execution policy before importing PSReadLine. Now we set it afterward.

Not sure what happens with PSSA here.

Ideally we could solve this by linking against those libraries rather than importing them as modules.

EDIT: It also turns out that Execution Policy scope order wasn't what we thought it would be, so we were setting a lower scope first. We now set the CurrentUser scope ahead of the LocalMachine scope.

ExecutionPolicy policyToSet = ExecutionPolicy.Bypass;
for (int i = policies.Count - 1; i >= 0; i--)
var currentUserPolicy = (ExecutionPolicy)policies[policies.Count - 2].Members["ExecutionPolicy"].Value;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this, can we rely on the order to remain consistent though?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other alternative is to look for user scope and then to look for machine scope

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I don't think there's any plan to update anything around execution policy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to start the extension properly with AllSigned execution policy
3 participants