question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PS extension sets execution policy?

See original GitHub issue

I’ve been hitting an issue where I couldn’t debug scripts because, even though my execution policy was set machine-wide to Bypass, my integrated console was reporting RemoteSigned.

It looks like this is set here but I’m not sure why. Shouldn’t we just inherit the right execution policy?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
rjmholtcommented, Feb 21, 2020

I was just having a similar thought! I’ll keep plugging on this

1reaction
SeeminglySciencecommented, Feb 21, 2020

So the remaining solution is to remember the initial execution policy and transmit that. The problem there is that the starting process is node, rather than PowerShell, meaning we’d need to start another PowerShell process to discover the execution policy, leading to greater startup time cost.

You can query the other scopes in the same process, so running something like below before we run profiles could work.

$userPolicy = Get-ExecutionPolicy -Scope User
if ($userPolicy -ne [Microsoft.PowerShell.ExecutionPolicy]::Undefined) {
    Set-ExecutionPolicy -Scope Process -ExecutionPolicy $userPolicy -Force
    return
}

$machinePolicy = Get-ExecutionPolicy -Scope Machine
Set-ExecutionPolicy -Scope Process -ExecutionPolicy $machinePolicy -Force

Does really make me wish setting it to Undefined wasn’t a no-op though…

Anyway, still not free, but cheaper than starting another process.

Read more comments on GitHub >

github_iconTop Results From Across the Web

about Execution Policies - PowerShell | Microsoft Learn
On non-Windows computers, the default execution policy is Unrestricted and cannot be changed. The Set-ExecutionPolicy cmdlet is available, but ...
Read more >
Set-ExecutionPolicy - PowerShell - SS64.com
By default, Set-ExecutionPolicy displays a warning whenever the execution policy is changed. -Scope ExecutionPolicyScope The scope of the execution policy.
Read more >
Set-ExecutionPolicy for Managing PowerShell Execution ...
In this post, you're going to learn about PowerShell execution policies and how to manage them with the Set-ExecutionPolicy cmdlet.
Read more >
15 Ways to Bypass the PowerShell Execution Policy - NetSPI
If you're looking at the setting for the first time it's likely set to “Restricted” as shown below. PS C:> Get-ExecutionPolicy. Administrator: ...
Read more >
2.6 Configuring the PowerShell Execution Policy
The PowerShell Execution Policy determines whether PowerShell scripts are allowed to run. By default, the Execution Policy is set to Restricted.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found