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

v1.2.0: Errors because of PowerShell execution policy #483

Closed
denisw opened this issue May 18, 2015 · 29 comments
Closed

v1.2.0: Errors because of PowerShell execution policy #483

denisw opened this issue May 18, 2015 · 29 comments

Comments

@denisw
Copy link

denisw commented May 18, 2015

The first time I start Cmder 1.2.0, I get an error that a script cannot be executed because the PowerShell execution policy doesn't allow it. After I have run Set-ExecutionPolicy Unrestricted as administrator, the shell asks me every time on startup whether I really want to run the script.

@SkynetHopper
Copy link

I ran set-executionpolicy remotesigned but now it shows that the profile.ps1 file is not digitally signed at all.

image

@Jackbennett
Copy link
Contributor

@SkynetHopper if you run get-executionPolicy -list is it shown as remoteSigned?

Have you both tried either right-clicking the powershell file in question and clicking button "unblock file"

Or you can point the unblock-file command at the profile.ps1 file. If that works I'll have to look at doing that in a setup step.

You should be able to leave your executionPolicy as remotesigned.

@SkynetHopper
Copy link

Thanks Jack! Unblocking the .ps1 file worked! But its missing git support
and asks to install posh-git and restart.

Running get-executionPolicy -list does show it as remoteSigned.

On Mon, May 18, 2015 at 1:27 PM, Jack [email protected] wrote:

@SkynetHopper https://github.com/skynetHopper if you run get-executionPolicy
-list is it shown as remoteSigned?

Have you both tried either right-clicking the powershell file in question
and clicking button "unblock file"

Or you can point the unblock-file command at the profile.ps1 file. If that
works I'll have to look at doing that in a setup step.

You should be able to leave your executionPolicy as remotesigned.


Reply to this email directly or view it on GitHub
#483 (comment).

@denisw
Copy link
Author

denisw commented May 18, 2015

I should stress that, while the problem might easily be fixa le by anyone with some PowerShell knowledge by themselves, it makes for a pretty bad user experience and first impression. It would be better if Cmder would set the execution policy itself if needed (and inform me about it), or if at least the docs would mention anything about the setup required.

@Jackbennett
Copy link
Contributor

You are correct. We are trying to find a balance between what we really need and not just changing global settings for users.

@MartiUK
Copy link
Member

MartiUK commented May 18, 2015

@denisw There isn't much we can do unfortunately, overriding built in security protections isn't something I'm willing to do, even though I feel they're a bit heavy handed.

@denisw
Copy link
Author

denisw commented May 18, 2015

@MartiUK If it isn't possible to make it nice, perhaps cmd.exe would be a better default choice after all as it works out of the box. I think that together with docs to make PowerShell work well, this would make the initial experience as nice as the one in 1.1 again.

@Jackbennett
Copy link
Contributor

I think there's a way around it, I'm making a new vm to test this stuff from scratch. The execution policy is more like a bad default and a not feature than it is for security.

What I don't want to is run the whole session in bypass.

@eliashdezr
Copy link

Running this as administrator did the trick for me.

Set-ExecutionPolicy -ExecutionPolicy Bypass

@OlsonDev
Copy link

So... the official solution is to open LocalMachine up to Bypass everything? Seems... bad.

EDIT: Just realized this issue was still open; thought it was closed due to "check the last comment" in #507.

@malobre
Copy link
Contributor

malobre commented Jul 1, 2015

If you don't want to use Set-ExecutionPolicy or it don't work (in my case the command is doing nothing) you can fix this by going into Settings > Startup > Tasks then select {PowerShell} or {PowerShell as Admin} and add -ExecutionPolicy Bypass to the command

@denisw
Copy link
Author

denisw commented Jul 1, 2015

Could we have cmd.exe as default again for v1.3 if this cannot be resolved automatically? At least that would work right away without error messages and configuration.

@malobre
Copy link
Contributor

malobre commented Jul 1, 2015

Or they could add -ExecutionPolicy Bypass to the default powershell task

@OlsonDev
Copy link

OlsonDev commented Jul 1, 2015

I much prefer Process being set automatically. Thanks @malobre!

@denisw
Copy link
Author

denisw commented Jul 1, 2015

I second that the @malobre's approach would be the most elegant one!

@Jackbennett
Copy link
Contributor

I just wish we could force to run our own init/profile script and drop back to remoteSigned

At least launching the process with -bypass is just for you cmder session and not anything that run on the computer. You wouldn't get any warning about running a script explicitly as .\fromInternet.ps1

I thought about signing our own script but we'd still have the same problem but with managing the key instead of the exec policy.

@isimmons
Copy link

Shouldn't cmd.exe be the default because it is always installed and in working order on all windows systems?

Added the policy bypass flag and then get error because I need to install posh-git module. Very frustrating to be forced into using powershell instead of simply giving instructions for those who want to use powershell.

How do I change this default task to use cmd.exe?

Update: found how to change it in the release notes https://github.com/bliker/cmder/releases

Also I see it is labeled as "The powershell release" So I will try to embrace powershell and if it doesn't work out, go back to the 1.1.4 release.

@LIGHTYEARS
Copy link

Thanks a lot!Unblocking the file profile.ps1 worked for me too.I navigate to the directory where contains the profile.ps1,then run command Unblock-File .\profile.ps1 and it succeed.

@ghost
Copy link

ghost commented Jul 19, 2015

For those who are having trouble with this, this is what I did to fix on Win10.
Right click cmder, open it as admin. It may or may not show the error, probably will. Either way, it starts PowerShell by default, so as long as its ran as admin this command should do the trick:
Set-ExecutionPolicy -ExecutionPolicy Bypass

@sfengyuan
Copy link

For those who have scrolled down here and still don't know how to fix it.
You can either run the command in the above comment or edit the commands in the setting->startup->tasks> powershell and powershell as admin, add this "-ExecutionPolicy Bypass".

@DavidDeme
Copy link

Is it possible to change settings and make cmd.exe default when Cmder starts ? :(
It's so annoying when I have to close powershell.exe first and then start a new console :(

@benjamin79
Copy link

setting->startup->tasks>default shell

@simevidas
Copy link

Could someone please give clear instructions how to get rid this error message? I’ve tried to follow instructions mentioned in the comments above, but nothing has worked so far.

capture

  1. Right-clicking on profile.ps1 does not show an “unlock file” button.
  2. Do I need to run Cdmer as administrator?
  3. In Settings > Startup > Tasks, in what order should the predefined tasks be listed and do I need to check Default task or Default shell for any of them?
  4. Where exactly do I need to append -ExecutionPolicy Bypass?

Stanzilla pushed a commit that referenced this issue Oct 12, 2015
@mflux
Copy link

mflux commented Dec 8, 2015

I'm still having issues with this despite having updated to the latest version.

@MartiUK
Copy link
Member

MartiUK commented Dec 8, 2015

1.2.9?

@Jackbennett
Copy link
Contributor

If you've not changed your execution policy you'll still get that with
powershell. The changes in later versions of cmder revert to using the old
cmd.exe instead to avoid it.

If you're a powershell user you need to set your execution policy as
described. I and MS recommend remotesigned.

So from an admin prompt, "Set-ExecutionPolicy RemoteSigned" then I think
you need to navigate into the cmder folder to run "unblock-file *"

On 8 December 2015 at 10:38, Martin Kemp [email protected] wrote:

1.2.9?


Reply to this email directly or view it on GitHub
#483 (comment).

@mcandre
Copy link

mcandre commented Jun 28, 2016

Unrestricted appears to be more secure than Bypass, and works on my machine for loading $HOME\profile.ps1 without trouble.

https://technet.microsoft.com/en-us/library/hh849812.aspx

@michael-wise
Copy link

#483 (comment)
As of recent versions (when?), it seems Cmder prompts to Powershell Unblock-file itself on first run. I am unsure if it checks on ExecutionPolicy as I believe mine was already set.

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

No branches or pull requests