Run multiple OSs together with Client Hyper-V and use the hosts Wi-Fi adapter for Internet connection

3:10 pm in Client Hyper-V, PowerShell, Wi-Fi, Windows 10, Windows 7, Windows 8.1, Windows XP by Wim Matthyssen

Hi all,

This is a follow up and enhancement to my previous blog post “Use Client Hyper-V and a shared Wi-Fi connection to run Windows 8.1 and Windows 10 Technical Preview simultaneous”, which you can find here: http://scug.be/wim/2015/04/20/use-client-hyper-v-and-a-shared-wi-fi-connection-to-run-windows-8-1-and-windows-10-technical-preview-simultaneous-2/

In this previous post, I set up a Windows 10 virtual machine (VM) on my Dell notebook running Windows 8.1 with Client Hyper-V. But why stop with just two Client Operating System (OS) running together? Therefore, I will show you how to automate an environment in which you can run multiple OSs (Windows 8.1, Windows 10 Technical Preview, Windows 7 with SP1 and finally Windows XP with SP3) using your notebooks Wi-Fi adapter to connect them to the Internet. If you’re an IT Pro or a software developer and need to do some testing, this is an easy way to do it.

I’ve you’re reading this I assume that you have already installed Client Hyper-V and added the necessary virtual networks, if not just follow steps 1 to 9 in my previous post.

Before starting some important remarks and tips:

  • Windows XP isn’t compatible with Hyper-V’s synthetic network adapter. As such, we will also need to do add a legacy network adapter for the sharing network.
  • Windows XP is not supported by Hyper-V’s Dynamic Memory feature, so we’ll need to use static memory instead.
  • Only W10 TP has the necessary Integration Services on board, that’s why after the OS installation, we will need to install them to the W7 and XP VM.
  • Before installation of the Integration Services in the Windows XP VM, you need to release the mouse and keyboard focus from the VM Connection window by pressing CTRL + ALT + LEFT ARROW.
  • The computer name of the W7 and XP VM is added when you install the OS. In my example I used W7-TST and XP-TST.
  • As a final remark, if you’ve installed the Windows 7 VM without SP1 you will receive the below error when trying to install the Integration Services.

clip_image001

1) For the automated built of the 3 VMs run the below PowerShell script. All virtual hardware will be added and configured and the OS ISO’s will be mounted. At the end the VMs will be started up to begin the OS installations. Please be aware that in order to us your shared Wi-Fi connection, the “InternalWifi” virtual switch needs to be attached to a legacy network adapter.

#----------------------------------------

#Author Wim Matthyssen

#Date 06/05/15

#Name BuiltClientOSVMs.ps1

#Usage Built several Client OSs VMs on Client Hyper-V

#Note Change variables were needed to fit your needs

#----------------------------------------

# Variables

$VM1 = "W10-TST" # Name of Windows 10 VM

$VM2 = "W7-TST" # Name of Windows 7 VM

$VM3 = "XP-TST" # Name of Windows XP VM

$VMRAMMIN = 512MB # Minimum RAM assigned to the VM

$VMRAMSTARTUP = 2GB # Startup RAM assigned to the VM

$VMRAMMAX = 4GB # Maximum RAM assigned to the VM

$VHDSIZE = 20GB # Size of fixed VHDX

$VMLOC = "D:\_VM" # Location of the VM and VHDX files

$NetworkSwitch1 = "InternalWifi" # Name of the Network Switch 1

$NetworkSwitch2 = "InternalShare" # Name of the Network Switch 2

$vCPUCOUNT=2 #Number of virtual CPUs

$W10ISO = "D:\Documents\Windows10_TP.iso" # Windows 10 ISO

$W7ISO = "D:\Documents\Windows7_SP1.iso" # Windows 7 with SP1 ISO

$XPISO = "D:\Documents\WindowsXP_SP3.iso" # Windows XP with SP3 ISO


# Create Windows 10 VM - Add Networks - Mount ISO

New-VHD –Path $VMLOC\$VM1\$VM1.vhdx –Fixed –SizeBytes $VHDSIZE

New-VM –Name $VM1 –Path $VMLOC

Add-VMHardDiskDrive -VMName $VM1 -Path $VMLOC\$VM1\$VM1.vhdx

Set-VMMemory $VM1 -DynamicMemoryEnabled $true -MinimumBytes $VMRAMMIN -StartupBytes $VMRAMSTARTUP -MaximumBytes $VMRAMMAX -Priority 80 -Buffer 25

Set-VMProcessor $VM1 –Count $vCPUCOUNT

Get-VMNetworkAdapter $VM1| Connect-VMNetworkAdapter –SwitchName $NetworkSwitch2

Get-VM $VM1 | Add-VMNetworkAdapter -IsLegacy $true -SwitchName $NetworkSwitch1

Set-VMDvdDrive -VMName $VM1 -Path $W10ISO

Start-VM $VM1


# Create Windows 7 VM - Add Networks - Mount ISO

New-VHD –Path $VMLOC\$VM2\$VM2.vhdx –Fixed –SizeBytes $VHDSIZE

New-VM –Name $VM2 –Path $VMLOC

Add-VMHardDiskDrive -VMName $VM2 -Path $VMLOC\$VM2\$VM2.vhdx

Set-VMMemory $VM2 -DynamicMemoryEnabled $true -MinimumBytes $VMRAMMIN -StartupBytes $VMRAMSTARTUP -MaximumBytes $VMRAMMAX -Priority 80 -Buffer 25

Set-VMProcessor $VM2 –Count $vCPUCOUNT

Get-VMNetworkAdapter $VM2| Connect-VMNetworkAdapter –SwitchName $NetworkSwitch2

Get-VM $VM2 | Add-VMNetworkAdapter -IsLegacy $true -SwitchName $NetworkSwitch1

Set-VMDvdDrive -VMName $VM2 -Path $W7ISO

Start-VM $VM2


# Create Windows XP VM - Add Networks - Mount ISO

New-VHD –Path $VMLOC\$VM3\$VM3.vhdx –Fixed –SizeBytes $VHDSIZE

New-VM –Name $VM3 –Path $VMLOC

Add-VMHardDiskDrive -VMName $VM3 -Path $VMLOC\$VM3\$VM3.vhdx

Set-VM -StaticMemory -Name $VM3 -MemoryStartupBytes 2GB

Set-VMProcessor $VM3 –Count $vCPUCOUNT

Remove-VMNetworkAdapter -VMName $VM3

Get-VM $VM3 | Add-VMNetworkAdapter -IsLegacy $true -SwitchName $NetworkSwitch2

Get-VM $VM3 | Add-VMNetworkAdapter -IsLegacy $true -SwitchName $NetworkSwitch1

Set-VMDvdDrive -VMName $VM3 -Path $XPISO

Start-VM $VM3

2) When you’re done installing the guest OSs, logon to your 3 new VMs.

3) Insert the Integration Services Setup disk to the W7 and XP VM.

clip_image003

4) On both VMs, if the installation doesn’t start automatically, open a command prompt and run d:\support\x86\setup.exe and select “Yes” to start the installation. When the Upgrade Hyper-V Integration Services box appears click “OK”. To complete the installation press “Yes” to reboot.

clip_image005

clip_image006

5) To check the version of the Integration Services through Device Manager, expand System Devices, right click Microsoft Hyper-V Virtual Machine Bus, and select Properties. Click the Driver tab and the Driver Version line will show you the version you’re running.

clip_image007

6) To prepare your host to connect to the shared folders and do the rest of the configuration for the W10 VM you can now follow steps 12 to 18 from my previous post.

7) To rename the network adapters for the W7 VM, logon, open a command prompt and run the following commands:

netsh interface set interface name = "Local Area Connection" newname = "WiFi"
netsh interface set interface name = "Local Area Connection 2" newname = "Sharing"

8) Logon to the XP to rename the network adapters. Open a command prompt and run the following commands:

netsh interface set interface name = "Local Area Connection" newname = "Sharing"
netsh interface set interface name = "Local Area Connection 2" newname = "Wifi"

9) On the W7 VM assign the fixed IP Address 33.0.0.3 for the “Sharing” network adapter from the command prompt (requires elevation).

netsh interface ip set address name = "Sharing" static 33.0.0.3 255.255.255.0

clip_image002[4]

10) On the XP VM assign the fixed IP Address 33.0.0.4 for the “Sharing” network adapter from the command prompt.

netsh interface ip set address name = "Sharing" static 33.0.0.4 255.255.255.0

clip_image004[4]

11) To share and to create the Temp folder on the W7 VM open a command prompt and run the following commands (requires elevation):

md C:\Temp
net share Temp=C:\Temp /GRANT:Everyone,Full

clip_image006[4]

12) To share and to create the Temp folder on the XP VM open a command prompt and run the following commands:

net user guest /active:yes
md C:\Temp
net share Temp=C:\Temp /unlimited

clip_image008[4]

13) To map the Temp folders from the 3 VMs on the host to the X, Y and Z-drive run the following commands in PowerShell (do not run PowerShell as an administrator)

New-PSDrive –Name X –PSProvider FileSystem –Root “\\W7-TST\Temp” –Persist -Credential W7-TST\username
New-PSDrive –Name Y –PSProvider FileSystem –Root “\\W10-TST\Temp” –Persist -Credential W10-TST\username
New-PSDrive –Name Z –PSProvider FileSystem –Root “\\xp-tst\Temp” –Persist -Credential XP-TST\username

clip_image010[4]

clip_image011[4]

14) As you can see in the below screenshot I’m able to surf with all OSs and share data between them.

clip_image013[6]

This concludes this blog post. Keep tuned and I’ll be back soon.