Understanding PowerShell Profiles In Visual Studio Code

If you’re writing PowerShell and haven’t used the PowerShell extension in Visual Studio Code yet, you’ve got a screw loose or you’ve been sticking your head in the sand for too long. As part of the extension comes profiles that allow Josh to magically run commands in a number of different contexts during his PowerShell development. Josh is my idol. Really.

This snip is a look at how the powershell extension for Visual Studio Code. Handles powershell profiles if I reload my window will see the integrated terminal pop up at the bottom and you can see that there are 4 warning messages. Each of those, 4 messages are coming from a different profile that top 2 are the profiles located in the system 32 folder. The bottom two are located in my documents folder notice that there's 2 labeled as being for the current host VS code and those will only ever run within this integrated terminal in Visual Studio code. You can find the location for any of these profiles by looking at the profile, variable for example, that all users or host. One is an system 32 Windows PowerShell Enders just profile dot PS one alternatively. The all users current host profile is in the same location, but it's prefixed with Microsoft dot VS code. It's possible to edit these profiles and if you prefix the path worth code. It'll open up their profile in code for editing within this window all open up the current user current host profile. Which happens to be the VS code specific profile that lives within my documents folder keep in mind that if you want to eat at the profiles there sit in the system 32 directory. You'll need to be running as admin also. Code will default to the Visual Studio Code specific version of the profile, if you only reference profile. This is where you should be putting any code specific to your sessions within Visual Studio code as this profile will not run in any other powerShell hosts if you don't want the powershell extension to load your profiles, you can configure a user setting. Cold powershell dot enable profile loading if you set that to false. And then reload your window you'll notice that the integrated terminal pops up. And but there are no warnings to displayed if however, we go back into our settings. And comment this out, making profile loading true again and save your profile you notice that instantly. The powershell extension has gone ahead and loaded those profiles. So we're going from no profile loading to tuning profile, loading on. We don't need to reload a window in order to trigger that loading process. That's been a very quick look at powershell profiles and visual studio code using the powershell extension. Thank you for watching.