Skip to content

Latest commit

 

History

History
9 lines (6 loc) · 583 Bytes

set-default-user.md

File metadata and controls

9 lines (6 loc) · 583 Bytes

Set the Default User back from Root after Importing WSL Distro

When you export a WSL distro then import it, the default user is switched to the root user. This will set it back to your username, rob in my case.

Function WSL-SetDefaultUser ($distro, $user) { Get-ItemProperty Registry::HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Lxss\*\ DistributionName | Where-Object -Property DistributionName -eq $distro | Set-ItemProperty -Name DefaultUid -Value ((wsl -d $distro -u $user -e id -u) | Out-String); };

WSL-SetDefaultUser <DistroName> <UserName>