Using Powershell as terminal in IntelliJ IDEA IDEs like PyCharm, PHPStorm or RubyMine

I have been attempting to run powershell as my terminal on windows in pycharm, so I did the following:

enter image description here

However, when I try this, it says that it cannot execute my scripts, and hence I get the following error: SecurityError and the Fully Qualified Id is : UnAuthorizedAccess.

This arises from the fact that pycharm's terminal cannot execute my Powershell_profile.ps1 profile file.

How can I successfully run Pycharm's terminal with Powershell?

What I have tried so far, is going into my main powershell directory as in %windir%/system32/WindowsPowerShell/1.0/profile.ps1, and then change it to include the following:

Set-ExecutionPolicy Unrestricted

However, this does not help, and I get the same error when I try to open of pycharm's terminal.

I have also tried to run pycharm as Admin, however this does not solve the problem either, and I get the same aforementioned error.


Solution 1:

I've replaced cmd.exe with powershell.exe in a simpler way and hope it can help. I'm using webstorm2017 and Win10 os.

1.Find the exact location of powershell.exe.In mine and I believe in most computers the location would be C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.Copy the whole path into your clipboard.

2.In your IDE open File=>Setting=>Tools=>Terminal, and paste the path into "Shell path" blank.

3.Restart the IDE and everything would be ok.

Solution 2:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

Solution 3:

  1. I updated the powershell.exe path in IntelliJ -> Settings -> Terminal

  2. Opened a powershell instance in Admin mode.

  3. Executed Set-ExecutionPolicy Unrestricted -Scope CurrentUser

  4. Restarted IntelliJ and the issue was solved.

Step 3 is from ebelanger's answer.

Screenshot of application settings. Shows the Shell path, the Tab name (Local), and all the options below are checked.

Solution 4:

Browse to the PowerShell executable, right-click, run as administrator.

From the prompt, use the same command you tried:

Set-ExecutionPolicy Unrestricted

Once that is done, close PowerShell, and attempt to use it again from your application.

Note: You can't set the execution policy from a script, as the default execution policy prevents you from running scripts. (even if it's the profile script - still a script)