I have a PowerShell script conda-init.ps1
that activates Conda via this single line:
(& "pathtocondaScriptsconda.exe" "shell.powershell" "hook") | Out-String | Invoke-Expression
I currently launch PowerShell using the arguments -noexit & pathtoconda-init.ps1
.
This does not work on machines where the PowerShell ExecutionPolicy
is set to Restricted
. Is there a way to instead pass the script contents as arguments to PowerShell, rather than the script file itself?
The end goal is to construct a VS Code terminal profile that mimics the behavior of the Anaconda prompt avoid having to pass a script file (as above) or running conda init powershell
(equivalent to passing a file, but makes it the default behavior of all Powershell prompts and still requires a non-restricted ExecutionPolicy).
2
Answers
The Miniconda prompt created during Miniconda install runs using the command
Which does use the
-ExecutionPolicy Bypass
command described by @maximilian-burszley. I can create an equivalent VS Code terminal profile in settings.json by adding the following entry toterminal.integrated.profiles.windows
:But it remains to be seen if this will work for users without admin permissions, as my experience is that non-admin users cannot bypass their execution policy.
This doesn’t need to be a powershell script at all. You can use a batch script: