Adding in WSL into Hyper-V VM in Windows Server

Default Windows OS doesn’t allow hyperV feature to be enabled in VM

Create nested Hyper-V

  1. Shut down the VM.
  2. In the host open Powershell with administrator rights.

    Set-VMprocessor ExposeVirtualizationExtension $true
    VMName

  3. Turn on VM.

Installation

  1. Open PowerShell with administrator rights

    Hyper-V is requirement for WSL installation
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V -All

    Enable WSL
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  2. Windows server does not have Microsoft store, we will have to download the distribution files.
    https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions
  3. Extract the .appx package’s contents, using PowerShell:

Copy-Item .\Ubuntu.appx .\Ubuntu.zip
Expand-Archive .\Ubuntu.zip .\Ubuntu

Add-AppxPackage .\app_name.appx

Add your Linux distribution path to the Windows environment PATH
$userenv = System.Environment::GetEnvironmentVariable("Path", "User")
[System.Environment]::SetEnvironmentVariable("PATH", $userenv + ";C:\Users\Administrator\Ubuntu", "User")

You can now launch your distribution from any path by typing .exe. For example:
ubuntu.exe.

After launching the ubuntu.exe you might encounter Kernel error. WslRegisterDistribution failed with error: 0x800701bc,

link to package https://learn.microsoft.com/en-us/windows/wsl/install-manual

Reference

https://learn.microsoft.com/en-us/windows/wsl/install-on-server

https://learn.microsoft.com/en-us/windows/wsl/install-manual#downloading-distributions

How to reset local administrator password

Step 1. If you have a Windows 10/server 2012/server 2016 installation disc in hand, then let’s continue. But if didn’t have a disc then you need to create a Windows 10 installation disc which can either be USB or CD/DVD first.

Step 2. Use this installation disc to boot your locked Windows 10 computer.

Step 3. Now as soon as the computer boots successfully, press “Shift + F10” to pop up the command prompt dialogue box.

Step 4. Execute the command given below to substitute utility manager with cmd and you must press “Enter” after every command in line.

move c:\of pc\windows\system32\utilman.exe c:\of pc\windows\system32\utilman.exe.bak

copy c:\of pc\windows\system32\cmd.exe c:\of pc\windows\system32\utilman.exe

reset windows password with command prompt

Step 5. Eject the disk and restart your computer by typing the “wpeutil reboot” in the cmd dialogue box.

Step 6. So now when the computer arrives at the login page, click on the utility manager icon at the bottom right corner of the screen, and the cmd black box would open up instead.

Type the following command

Step 7. Type the following command to create a new admin and hit “Enter” to reset a new password:

net user <username> <password>

Step 8. Restore the utility manager once again with the help of installation disc, and reboot your computer.

Step 9. Use the newly created password to sign in to your locked admin account.