How I Setup My Powershell Development Environment

In this post i will walk through the process of how i setup my PowerShell development environement on a Windows PC. This guide has been made on a Windows 11 PC, so if you are running Windows 10, you might experience that some of the application or tools, need to be installed a different way.
In this tutorial i will show how to setup the two package managers Scoop and Chocolatey, I will show you to use the package managers to install tools like: vscode, git and neovim. I will also show how to setup WSL2, Docker Desktop and neovim for editing PowerShell scripts in the Terminal.
Prerequisites
- Windows 11 PC
- Connection to the internet
Installing the Chocolatey and Scoop package Managers
I try to install as many tools and applications as possible through one of the two package managers. The reason for this, is that with the package manager you have easy access for updating your applications, and it is extremely easy compared to go out to different websites, finding the correct version, downloading and installing through a GUI.
Installing Chocolatey
For installing chocolatey it is as easy as running a simple PowerShell command.
-
Open a PowerShell terminal as Administrator
-
Run the following command:
|
|
- You now have Chocolatey installed. To verify this you can run the following command:
|
|
output:
|
|
Important thing to know is that whenever you want to install a package with chocolatey you will need to open the PowerShell terminal as Administrator.
Installing Scoop
For installing Scoop it is just as simple as installing Chocolatey, and can be done with a single command
-
Open a PowerShell terminal as Administrator
-
Run the following command:
|
|
- You now have Scoop installed. To verify this you can run the following command:
|
|
output:
|
|
Important to know is that if you are installing packages with scoop, you may sometimes need to use a PowerShell terminal in Administrator context, and sometimes in User context. I usually start by trying with a non-administrator PowerShell terminal.
Now you might need to add Scoop to your Environment Variable Path, before you can actualy use the package manager.
Updating the Windows Terminal
Depending on which build you are on, you might need to update your Windows Terminal application to a newer version, to get some newer features. In my case i needed to update the application.
Now you can either completely uninstall the application and then install it through Chocolatey by running the command:
|
|
You can also just update the application through the Microsoft Store. You do this by opening the Store, search for “Windows Terminal” and click on “Update”.
Installing Windows Subsystem for Linux
I use Windows Subsystem for Linux quiet a bit, for developing PowerShell 7 scripts for Linux or different applications such as Python.
To install WSL2 open a PowerShell terminal as administrator and enter the command:
|
|
The installing will take a couple of minutes and once done, you will need to restart the computer.
Now as default WSL2 will install Ubuntu on you system. So once your computer has restarted you will be prompted to complete the setup of you Ubuntu instance.
To complete the ubuntu setup you will need to select a Username and Password for the user.
I always run a complete update of the Ubuntu instance with the command:
|
|
Installing Packages
I always install the following packages:
Package | Description | Package Manager |
---|---|---|
VSCode | IDE for writing code | Chocolatey |
git | Source Control application | Chocolatey |
Docker Desktop | Container runtime, and management application | Chocolatey |
Picpick | Screenshot tool | Chocolatey |
Neovim | Terminal text editor | Scoop |
Fuzzy | Terminal Search tool | Scoop |
Curl | Terminal http tool | Scoop |
Sudo | Terminal tool for administrator elevation | Scoop |
Jq | Terminal json parsing tool | Scoop |
Installing the Chocolatey Packages:
|
|
Installing the Scoop Packages:
|
|
Installing PowerShell 7
You can install PowerShell 7 in two different ways. You can either install it through the MSI provided by Microsoft on their website, or you can install it through Chocolatey
Installing through Chocolatey:
|
|
Installing through Microsoft provided MSI:
Link to Microsoft Docs - Installing PowerShell 7
Both ways provide PowerShell 7 version 7.2.3 at the time of writing this post. But if you wanted to run with PowerShell preview you could install it through Chocolatey by running the command:
|
|
Now i would usually try out a preview version in a Docker container, and then running a stable version on my system.
Installing a Nerd Font
To be able to use oh-my-posh and Terminal-Icons in the terminal, which I will show in the next step, you will need to install a Nerd Font and set it up in Windows Terminal. The reason for this is that a Nerd Font is able to display icons in the terminal, which a regular font is not.
First you will need to download a Font, and you do this by going to Nerd Fonts downloads page and then selecting a font you like. I usually go with Hack Nerd Font.
Once the fonts are downloaded, you will need to extract the content. Then in the extracted folde, select all the files. Right click and then select ‘Install’. This will install the font to your system.
All you need to do now is to select the font as default in your Windows terminal. You do this by opening Settings, and under “Profiles” select “Defaults”. Then under “Additional settings” select “Appearance”, and under “Font face” you can now select the font you downloaded.
Setting up my PowerShell Terminal
I have my PowerShell terminal setup with some specific tools which helps me when working in git repositories, and with some tools for easy navigation in the terminal.
First i will need to install a tool named oh-my-posh. This tool is used for showing different information in terminal, such as which directory you are in, and status of your git repository.
To install oh-my-posh run the command:
|
|
Then I will install the following PowerShell modules:
- ‘Terminal-Icons’ - (used for showing icons in the terminal such as directories and files)
- ‘Z’ - (This module is a directory navigation tool)
- ‘PSFzf’ - (Directory Navigation and file searching tool for the terminal)
- ‘PSReadLine’ - (Tool for providing autosuggestion and completion in the terminal based on history)
Install the modules by running the commands:
|
|
The last thing i will do is to configure my PowerShell profile. I only run some simple thing in the profile, such as importing modules, initializing oh-my-post and setting som aliases.
to create a PowerShell profile run the command:
|
|
Then add the following to the .ps1 script
|
|
Save the file, and in your powershell terminal you will need to re-initialize the PowerShell profile
|
|
Configuring VSCode
I have a very basic setup for my vscode. I only install a handfull of extensions and then i set some custom hotkeys, for switching between the editor and the terminal.
Installing vscode extension
For installing the extensions i have created a very simple script which runs through an array of extensions and installs them. You can edit the array as you like, and then just run the script.
|
|
Configuring vscode hotkeys
To configure the hotkeys, open vscode, pres ctrl+shift+p to open the command pallet. Then search for ‘Shortcuts’ and open the ‘Preferences: Open Keyboard Shortcuts (JSON)’.
Then add the following lines between ‘[]’
|
|
These hotkeys allow you to switch between the editor and the terminal with the hotkeys: ‘alt+right’ and ‘alt+left’
Configuring Neovim
I use Neovim queit often, since i am using the terminal for pretty much everything which have to do with navigation in Windows, and often i will need to edit a single line in a script of config file. Instead of having to open a vscode editor it’s usually easier and quicker to just open til file inside Neovim.
Neovim comes pretty standard which might not be the easiest way to edit PowerShell scripts with.
First you will need to creat the init.vim config file. This file is where all the configs for the editor is located.
Create the following files:
|
|
Then run the following command to install vimplug:
|
|
Then open the file: init.vim in vscode and add the following settings:
|
|
Now you will need to install the different plugins for PowerShell syntax highlighting and code completion. To do this open Neovim by entering ‘vim’ in the terminal.
Then press ‘:’ and write PlugInstall
This will install all the needed plugins.
The only thing left to do is to create a new file for disabling the integrated terminal in Neovim.
open a new vim editor and write
:CocConfig
Then add the following to the file:
|
|
You should now have a working Neovim setup for editing and writing Powershell code
Using the different tools
In this finishing section i will just quickly walk over how to use some of the tools or how to look
The Oh-My-Posh module and the Terminal Icons Tool
Using the PSReadLine
The configs for the PSReadline is set to use the PowerShell command history to autosuggest possible commands:
Using the Module Z
The Module Z is a quick directory Navigation tool.
Use the following command to see possible directoris:
|
|
The go to a directory by adding a word from one of the directories after a ‘z’:
|
|
Using Fuzzy Finder
Use ‘Ctrl+r’ to navigate through your powershell history. If you type something the list will narrow to the specific text.
Use ‘Ctrl+f’ to search through your current directory