Scoped VS Code Powershell profile

No Comments

As of writing, I am working on a very controlled client environment (i.e. Citrix session) where the home drive is in a network share, and the machine session has a locked policy of only allowing signed poweshell scripts to execute.

I have my scripts in the Powershell folder which then gets this error because they are not digitally signed.

A solution presented is to run a new powershell session with the execution policy for the current user set to Bypass. Normally this needs to be done as an admin but it should be doable using the normal user. I wanted this to be part of my VS Code setup and this is how I configured it:

  • Go to File->Preferences->Settings dialog (or press Ctrl+,)
  • In the search box, type in “@feature:terminal integrated.profiles.windows”
  • Click on the “Edit in settings.json” link to open the correct settings file.
  • Locate the Powershell entry and add the following argument stanza to the “terminal.integrated.profiles.windows” section.
    "args": [        
                "-noexit",      
                "-ExecutionPolicy",
                "Bypass",
                "-file",        
                "H:\\PowerShell\\functions.ps1"      
            ]  

  • Save the changes. This will now take effect in new terminal sessions started by VS Code using that profile.