Understanding $env:PSModulePath

OK… So this is probably old news for most of you but I thought I would document this here mostly for me.

When you start a powershell prompt whether it being the old and battletested version 5.1, the brand new 7.x or if you are running the cool new windows terminal or my favorite VS Code you will get a couple of environemnt variables set by default. One of these are $env:PSModulePath. The problem is that they look a little different depending on which application you look in.

PowerShell 5.1:
C:\Program Files\WindowsPowerShell\Modules;

One folder for the current user and 2 system wide folders

Powershell 7:
C:\Program Files\PowerShell\Modules;
c:\program files\powershell\7\Modules;
C:\Program Files\WindowsPowerShell\Modules;

A couple of notable differences. PS7 uses PowerShell in your documents folder while PS5 uses WindowsPowerShell. If you have set up OneDrive with known folder redirection for My Documents the first path will instead start with C:\Users\[UserName]\[OneDrive folder]\Documents. Lastly version 7 also migrates the system wide folders for version 5.1 and adds them to the variable so your old Modules will be available there as well. You will see four system folders and one for the user. You might have issues with the OneDrive storage if you do not set the folder to “Always keep on this device”

If you are running VS Code the Powershell Addin will add its own folder called c:\Users\[UserName]\.vscode-insiders\extensions\ms-vscode.powershell-preview-2020.9.0\modules

Another notable thing with VS Code Preview is that you have two different consoles for PowerShell. One called PowerShell and one called PowerShell Integrated console, the first one runs version 5.1 and the second runs 7.

The all new Windows Terminal of course also has the option to run both version

That was it for today…


Getting started with VS Code – for a developer wannabe – Part 1

I am a developer… in the same was as I am a gamer and a harmonica player… I really, really really want to be one… I am not good at it, but I really want to be one. I have over the years tried my hand at Powershell, Yaml, BAT- files and even good old kix scripts and much lite an amateur golfer I try to tell my self that if I just have the right tool I will really get good at this… (I really want to believe that 🙂 )

When it comes to PowerShell I have been an avid user of PowerShell ISE but since Microsoft is not doing much of anything with ISE anymore and they are pushing VS Code more and more for everything I thought what the heck… This is my noob guide to getting started with VS Code (for someone that has only used ISE).

In this post I will show you how I set it up and I will probably follow up wit other posts on how I got started.

First you need to download and install VS Code itself:

  1. Go here to download
  2. I checked the options
    Add “Open with Code” action to Windows Explorer file context meny
    Add “Open with Code” action to Windows Explorer directory context meny
    Register Code as an editor for supported file types
  3. Finish the install and Launch VS Code

When you start VS Code for the first time it will look like this. To get started with PowerShell there is at least one plugin you will need… PowerShell (unexpected right). This is used for providing snippets and high lighting code

4. Click the small cubes at the bottom of the toolbar on the left

5. Type PowerShell in the search bar, select it and press the small green install

The plugin even makes VS Code look a bit like ISE. I usually set it back to Dark (that is what coders do 🙂 )

That is it for today. I will continue with more tips and tricks for getting started with VS Code.