How to improve your Workstation setup

Mon, Feb 22, 2021 3-minute read

Typically, you don’t install your operating system and all the tools too often. However, I had to do that exactly several times in the past two months. The first time is still exciting, because you deal with the new functions and tools. The second time at the latest, the work through the configuration is annoying.

With this article I want to show how you can (partially) automate the installation and configuration of your tools and thus achieve a repoducible working environment.

tl;dr: I use a powershell script for installation and configuring my tools. You can find it in my GitHub repository.

Prerequisits

I install my tools via with winget. Currently it is still in the status of a preview and has only limited functionality. But for my purposes it is fully sufficient. You have the choice to get it from the Windows Insider Program or directly as a release from GitHub Repository.

Start a Powershell session as administrator

Set-ExecutionPolicy Unrestricted
32
33
Invoke-WebRequest https://github.com/microsoft/winget-cli/releases/download/v0.2.2941-preview/Microsoft.DesktopAppInstaller_8wekyb3d8bbwe.appxbundle -OutFile winget.appxbundle
Add-AppxPackage winget.appxbundle

Setup WSL2

Due to the possibilities that arise from WSL2, I have completely switched and containerize all services that is possible. You need Windows 10 Build 1903 or later.

37
38
39
40
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Enable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart
wsl --set-default-version 2

Then you have to get the preferred Linux distribution from the Windows Store. I prefer Ubuntu. Unfortunately, this step cannot be automated.

Install software

This is the software I use on a regular basis. You may want to modify it to your specific needs.

46
47
48
49
50
51
52
53
54
55
56
57
58
winget install 7Zip
winget install Amazon.AWSCLI
winget install Epiforge.Grindstone
winget install Git.Git
winget install Greenshot.Greenshot
winget install Microsoft.WindowsTerminal
winget install Microsoft.VisualStudio.Professional
winget install PDFsam.PDFsam
winget install screentogif
winget install Docker.DockerDesktop
winget install Microsoft.SQLServerManagementStudio
winget install winmerge
winget install vscode

Install VSCode modules

This as the extensions I use on a regular basis within VSCode. You may want to modify it to your specific needs.

80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
code --install-extension ms-vscode-remote.remote-wsl
code --install-extension scala-lang.scala
code --install-extension asciidoctor.asciidoctor-vscode
code --install-extension yzhang.markdown-all-in-one
code --install-extension christian-kohler.path-intellisense
code --install-extension eamodio.gitlens
code --install-extension esbenp.prettier-vscode
code --install-extension ms-azuretools.vscode-docker
code --install-extension ms-dotnettools.csharp
code --install-extension ms-vscode.azure-account
code --install-extension ms-azuretools.vscode-azurestorage
code --install-extension ms-dotnettools.csharp
code --install-extension ms-mssql.mssql
code --install-extension ms-vscode.powershell
code --install-extension redhat.vscode-yaml
code --install-extension VisualStudioExptTeam.vscodeintellicode
code --install-extension vscode-icons-team.vscode-icons

Setup Eye-Candy

The new Windows Terminal is an awsome replacement for the old cmd. To even improve the experience I use oh-my-posh with posh-git as extension. There are many different themes if they don’t like mine.

 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
Install-Module posh-git -Scope CurrentUser
Install-Module oh-my-posh -Scope CurrentUser
# Start the default settings
Set-Prompt
# Alternatively set the desired theme:
Set-Theme Sorin

if (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force }
Add-Content $PROFILE @'
Import-Module posh-git
Import-Module oh-my-posh
Set-Theme Sorin
'@

$installFolder = Get-ChildItem $env:LOCALAPPDATA/Packages | Where-Object { $_.Name.StartsWith("Microsoft.WindowsTerminal") }

if ($installFolder.Count -eq 1) {
    Install-Fonts "./Meslo LG L Regular Nerd Font Complete Windows Compatible.ttf"
    Copy-Item settings.json $installFolder.FullName/LocalState -Force
}

After that, the terminal session looks like this.

Windows Terminal

Windows Terminal

Windows Terminal with Git

Windows Terminal with Git

Clean up

We now reset the execution policy to the default value.

Set-ExecutionPolicy Default

I hope you enjoyed my approach. If you have any comments or additions let me know.