The WSL Onion

Calling powershell.exe from PowerShell inside WSL

The other day I was playing around in WSL with a colleague of mine and we did this: # We start out in WSL Debian and enter PowerShell Core marco@box:~$ pwsh PowerShell 7.2.2 Copyright (c) Microsoft Corporation. Type 'help' to get help. # Then we get the major version of the active PowerShell session PS /home/marco> ($PSVersionTable.PSVersion).Major 7 # Then we call powershell.exe and get a completely different version! [Read More]

Hidden WSL Fileshare

WSL file systems get exposed as a hidden share network share: \\wsl$\<WSL Name>\<path\to\file>

For example, my Debian home folder is at: \\wsl$\Debian\home\kamner

wsl  windows 

Windows Terminal: Open New WSL Tab In Linux Home Folder

The path you are in when opening a new WSL tab is determined by startingDirectory. This parameter needs to be a valid Windows path, which isn’t great if we want to end up in /home/kamner inside WSL. The nice thing about WSL is that it will resolve windows paths into their equivalent WSL/linux path if possible. For example, C:\Scripts would resolve to /mnt/c/Scripts. Using this and the neat trick that the WSL filesystem is exposed as a a hidden fileshare ([[technology/windows/wsl-hidden-fileshare]]) we can get to where we want. [Read More]

Why You Want To Install PowerShell On Windows

Why installing PowerShell on Windows may actually be a good idea

Q: Wait a minute! Don’t I already have PowerShell? A: Yes. However you may want to continue reading because things are never as simple as they appear. The PowerShell version you have installed on Windows 10 is 5.X, Microsoft even says so in their own documentation. On the initial release of Windows 10, with automatic updates enabled, PowerShell gets updated from version 5.0 to 5.1. If the original version of Windows 10 is not updated through Windows Updates, the version of PowerShell is 5. [Read More]