You are browsing the archive for Client Hyper-V.

PowerShell: BgInfo Automation script

9:19 am in BgInfo, Client Hyper-V, Hyper-V, PowerShell, scvmm, VM Template, Windows Server 2016, Windows Sysinternals, WS2016 by Wim Matthyssen

Probably everyone knows the Windows Sysinternals tool BgInfo (currently version 4.21). For those who don’t, it’s a great free tool which captures system information from a workstation or server (probably where it is the most useful) and displays the catched data on the Desktop of that machine. It can show useful information like, DNS settings, used IP Addresses, computer name, domain name, OS version, memory, etc. If you want to read more about this tool you can do so via following link: https://technet.microsoft.com/en-us/sysinternals/bginfo.aspx

Whenever I create a new Windows Server 2016 Virtual Machine (VM) template for customers, I mostly add this tool in the base image (also called golden image) and set it so it starts up automatically whenever a user logs on to the server. To automate this process, I wrote a PowerShell script which does all of the following:

  • Download the latest BgInfo tool
  • Create the BgInfo folder on the C drive
  • Extract and cleanup the BgInfo.zip file
  • Download the logon.bgi file which holds the preferred settings
  • Extract and cleanup the LogonBgi.zip file
  • Create the registry key (regkey) to AutoStart the BgInfo tool in combination with the logon.bgi config file
  • Start the tool for the first time

Prerequisites

Windows PowerShell 5.0

PowerShell script:

To use the script copy and save the above as BGInfo_Automated_v1.0.ps1 or download it here. Afterwards run the script with Administrator privileges from the server you wish to use for your VM template. If you want to change configuration settings, just open the logon.bgi file and adjust the settings to your preferences.

image

image

image

image

Hope this script comes in handy for you. If you have and questions or recommendations about it, please contact me through my twitter handle.

Wim Matthyssen (@wmatthyssen)

2016: My blog year in an overview

2:37 pm in Azure, Azure Backup, Azure RemoteApp, Client Hyper-V, Cloud, DC, Hyper-V, IaaS, PowerShell, Private Cloud, Public Cloud, Replica DC, SCAC 2012 R2, SCVMM 2012 R2, System Center 2016, W2K12R2, Windows 10 by Wim Matthyssen

Hi all,

As a blogger completely focused on Microsoft technologies, it was a fun year of writing about all those interesting and ever changing products and services. As we almost end the year 2016 and are preparing for 2017 to start, I wanted to make a list of all the blog posts I wrote throughout the twelve months of 2016. During the year, I’ve published 26 blog posts mostly about Azure, the System Center Suite and Hyper-V. Below you can find them all divided by technology.

 

clip_image002

Azure Compute – IaaS (ASM)

Step-by-step: Move an Azure IaaS VM between different Azure Subscriptions

Clean up Azure PowerShell when using different Azure subscriptions

Replica DCs on Azure – Removing the Azure Endpoints

Replica DCs on Azure – Transferring FSMO roles to the IaaS DCs

Replica DCs on Azure – Manage the Time Configuration settings on the DCs

Replica DCs on Azure – Domain Controller Health Check

Replica DCs on Azure – Promote the Azure IaaS VMs to a domain controller

Replica DCs on Azure – Add the Active Directory Domain Services role

Replica DCs on Azure – Adjustment of some server settings before promoting the DCs

Replica DCs on Azure – Initialize and format the additional data disk

Replica DCs on Microsoft Azure – Create the VMs with Azure PowerShell

Step by step: Change the drive letter of the Temporary Storage on an Azure IaaS v1 VM

 

Azure Networking

How to connect an Azure ARM VNet to an ASM VNet using VNet Peering

Replica DCs on Azure – Switch DNS servers for the VNet

Replica DCs on Azure – Create the Active Directory site for the Azure VNet

 

Azure Backup

Microsoft Azure Backup Server: Install a new version of the Microsoft Azure Recovery Services Agent

Microsoft Azure Backup Server: System State backup fails with WSB Event ID: 546

Microsoft Azure Backup Server: System State backup fails with the message replica is inconsistent

Step by step: How to install Microsoft Azure Backup Server (MABS)

 

Azure RemoteApp

An RDP connection to the Azure RemoteApp custom VM fails with the following error: “No Remote Desktop License Servers available”

 

Windows 10

How to deploy Windows 10 from a USB flash drive

 

System Center

System Center 2016 evaluation VHDs download links

Step by step: How to connect SCAC 2012 R2 to SCVMM 2012 R2 and Microsoft Azure

Step by step: Installing SCAC 2012 R2

 

Hyper-V

A list of tools that can be used to do a V2V from VMware to Hyper-V

Client Hyper-V – Using nested virtualization to run Client Hyper-V on a Windows 10 VM

 

Before I wrap up this blog post, I want to thank you all for reading my blog posts in 2016, and I really hope you will keep doing so in 2017. I wish you all a healthy, successful and outstanding New Year! See you all in 2017!

Wim Matthyssen (@wmatthyssen)

Client Hyper-V – Using nested virtualization to run Client Hyper-V on a Windows 10 VM

7:37 pm in Client Hyper-V, Hyper-V, Nested Virtualization, PowerShell, W2K16 TP5, Windows 10 by Wim Matthyssen

From Windows 10 build 10565, Microsoft added a long awaited feature called nested virtualization. This technology will allow you to run Hyper-V inside of a virtual machine (VM) running on a Windows 10 (Client Hyper-V) or Windows Server 2016 host. In other words, in the simplest configuration it enables you to install Hyper-V in a guest VM, whit the possibility to create and also run VMs on top of that Hyper-V host VM. Completely different than the previous situation with Windows Server 2012 R2 or Windows 8.1, were you could create the VMs, but weren’t able to actually start them. This new feature kind of creates a second virtualization layer, like shown in the detailed screenshot below.

clip_image002

This new technology is very useful when you are setting up a test/lab environment because there is no need to buy a lot of expensive hardware anymore, it simply can run on top of your notebooks OS. It also comes in handy whenever you want to train you’re failover clustering or even your System Center skills. But it’s main purpose and probably Microsoft’s main reason to finally created this feature, is to enable you to work with Hyper-V containers (operating system level virtualization). If you’re interested in reading more about this type of containers you can do so via following link: https://msdn.microsoft.com/en-us/virtualization/windowscontainers/management/hyperv_container

Now before we start playing around with this new feature, I will first list up some things you should really keep in mind:

  • The Hyper-V host must be running at least Windows 10 build 10565 or Windows Server 2016 Technical Preview (TP) 4
  • An Intel processor with Intel VT-x (AMD-V is not supported yet) and EPT technology is needed to be able to use Hyper-V
  • Currently only Hyper-V is supported, all other hypervisors like for example vSphere ESXi will fail to run
  • Be aware that some VM features are not supported or will fail: Dynamic Memory, applying checkpoints, Live Migration and save/restore, hot memory resizing
  • The VM should have more than 1 vCPU
  • At least 4 GB RAM should be attached to the VM
  • MAC address spoofing must be enabled on the NIC attached to the VM
  • If you’re using Windows 10 Enterprise as the host, you should turnoff Virtualization Based Security (VBS) because it will prevent the use of nested virtualization
  • Plenty of available RAM is needed (at least more than 4GB of RAM is preferred to get started)

After going through the theory it’s now time to get our fingers wet and get everything up and running. I will walk you through all the different steps needed to use this feature on a Windows 10 Enterprise computer. In my example I will setup a generation 1 VM (Windows 10) with a PowerShell script to test the nested virtualization scenario. So off we go.

1) First of all, you should check your windows version (should be build 10565). Click run and type winver

clip_image003

clip_image004

2) Create two internal virtual switches, one is to use your wireless card and the other one will be used in a later step as a Hyper-V vSwitch inside the VM

clip_image006

3) To install the VM, run the following PowerShell script (customize to your need).

clip_image008

clip_image010

4) Go through the Windows Setup Installation Process on the newly created VM

5) When installation is completed shutdown the VMs and run following PowerShell commands on the Windows 10 computer (host) to set the Virtualization Extension for the vCPUs and to enable MAC spoofing on both VMs. Be aware a warning message will appear that Nested Virtualization is an unsupported preview feature. When both commands ran successfully start up the Windows 10 VM

clip_image012

6) To configure the W10-TST VM and to install the Client Hyper-V role with all tools, run the following PowerShell script (customize to your need). Connect to the VM with a Virtual Machine Connection with Enhanced session enabled

7) To create an external virtual switch on W10-TST, logon to this sever with RDP and run the following PowerShell cmdlet as administrator (customize to your need)

clip_image014

8) To create a nested VM named VM1-NESTED on W10-TST, logon to this VM with RDP and run the following PowerShell script as administrator (customize to your need)

clip_image016

9) Go through the Windows Setup Installation Process on the newly created nested VM named VM1-NESTED on W10-TST

10) If the installation is successful, you should now have a nested VM running like in the screenshot below

clip_image018

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

Wim Matthyssen (@wmatthyssen)

How to use mRemoteNG to connect to multiple Client Hyper-V VMs with RDP in a tabbed view

7:56 pm in Client Hyper-V, RDP, Windows 10 by Wim Matthyssen

From Windows 10, Client Hyper-V supports nested virtualization (basically it means that it allows you to run Hyper-V in a Hyper-V virtual machine), something many people were awaiting for a longtime. It also brings other nice new features to the built-in hypervisor like:

  • Windows PowerShell Direct
  • Hot add and remove network adapters and memory
  • Linux secure boot
  • Integration Services delivered through Windows Update
  • A new virtual machine configuration file format .VMCX

I’ve you’re interested in reading more, you can do so via following link:

https://msdn.microsoft.com/en-us/virtualization/hyperv_on_windows/about/whats_new

Because of all those nice improvements I decided to create my new demo and testing environment with it on my notebook. When Client Hyper-V (optional feature) was installed and the VMs for the complete infrastructure were built, I had the ability to connect to those VMs via two mechanisms: the VM console (VMConnect) and Remote Desktop (RDP).

The VM Console provides a single monitor view of the VM with resolution up to 1600 x 1200 in 32-bit color. This console also provides you with the ability to view the VM’s booting process. You can use it by opening the Hyper-V Manager, right clicking a VM, and select Connect…

clip_image002

If you want a richer experience, you can connect to a VM using an RDP connection. Then the VM will take advantage of the capabilities available on your notebook (multi monitor use, full media capability, shared clipboard, USB redirection and much more). You can use it by opening Run and typing mstsc (like everyone probably knows).

clip_image003

Because you’re mostly working with more than one server in a lab environment, it’s not so easy and practical to use the VM Console. Simply because there is no tool available to manage multiple VM Console connections in a tabbed view, which allows you to switch easily between all those running VMs.

When you use RDP instead to connect to those VMs several of such tools (free or paid) are available:

Before we start, first some practical information and tips:

  • I will be using mRemoteNG to use multiple RDP connections in a tabbed view
  • The IP range used is 192.168.0.0
  • Two VMs will be used in this example: GR-DC-01 and GR-DC-02
  • In all steps PowerShell is used with administrator rights
  • When you use a generation 2 VM, set the Firmware setting to Boot from Hard Drive
  • To use an RDP connection from your notebook to a VM running in Client Hyper-V an internal virtual switch needs to be connected to the VM

1) First of all an internal virtual switch needs to be created on the host. So open PowerShell and run the following command:

New-VMSwitch -Name InternalRDP -SwitchType Internal -Notes 'RDP connection'

clip_image005

2) You can check if the virtual switch is created correctly by opening up your Hyper-V Manager and click on Virtual Switch Manager

clip_image007

3) Still on the host, assign the static IP address 192.168.1.100 to the network adapter that was created for the virtual switch “InternalRDP”. Open up PowerShell and run following commands:

#Retrieve the wright network adapter

$netadapter = Get-NetAdapter -Name “vEthernet (InternalRDP)”

#Disable DHCP

$netadapter | Set-NetIPInterface -DHCP Disabled

#Configure the IP address

$netadapter | New-NetIPAddress -AddressFamily IPv4 -IPAddress 192.168.1.100 -PrefixLength 24 -Type Unicast

clip_image009

clip_image011

4) Connect both VMs to virtual Network Adapter to the InternalRDP virtual switch by use of PowerShell

#Add Networks

Get-VMNetworkAdapter GR-DC-01| Connect-VMNetworkAdapter –SwitchName InternalRDP

Get-VMNetworkAdapter GR-DC-02| Connect-VMNetworkAdapter –SwitchName InternalRDP

clip_image013

clip_image015

5) Logon to both VMs with the VM Console and rename the network adapters with PowerShell

Get-NetAdapter -Name Ethernet | Rename-NetAdapter -NewName Internal –PassThru

clip_image017

clip_image019

6) On VM GR-DC-01 assign the fixed IP address 192.168.1.10 with subnet mask 255.255.255.0 for the “Internal” network adapter

clip_image020

7) On VM GR-DC-02 assign the fixed IP address 192.168.1.11 with subnet mask 255.255.255.0 for the “Internal” network adapter

8) Enable RDP on both VMs

clip_image021

9) If the Windows Firewall is enabled, don’t forget to adjust the necessary Inbound Rules to allow RDP

clip_image023

10) Open mRemoteNG, right click Connections and select “New Connection”. Create two new connections named “GR-DC-01” and “GR-DC-02”. When created fill in all necessary info like shown in the screenshot below (I log in with the local administrator, that’s why I filled in .\ for the domain).

clip_image024

11) Click both connections and you will see that you can use both VMs in a tabbed view by using RDP

clip_image026

clip_image028

That’s all, hope it helps!

Wim Matthyssen (@wmatthyssen)

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.

Use Client Hyper-V and a shared Wi-Fi connection to run Windows 8.1 and Windows 10 Technical Preview simultaneous

11:22 am in Client Hyper-V, PowerShell, Wi-Fi, Windows 10, Windows 8.1 by Wim Matthyssen

With the official release of Windows 10 in the pipeline somewhere this summer, I wanted to play around with the Windows 10 Technical Preview (WTP). My idea was to use Client Hyper-V on my Dell notebook, running Windows 8.1, and build a virtual machine (VM) with the latest W10 WTP build (9926) on top of it. In this way, I could run both operating systems (OSs) together on the same desktop and see all what is changed.

The above set-up will allow me to test the new Windows 10 features (such as the new browser Project Spartan, Cortana, Continuum, the new start menu and lots of other nice improvements). Upon that, I will still be able to do some productive work on my Windows 8.1

Please note if you want to download the latest W10 WTP you need to join the Windows Insider program. You can become a member via the following link: https://insider.windows.com/. Just press the “Get Started” button and follow the procedure. If everything is filled in and confirmed, you can download the WTP of this bright new OS.

But enough said it’s time to get our fingers wet and get everything up and running. Like mentioned above, I will walk you through the different steps I followed to run both OSs simultaneous. Both of them will be able to access the Internet with use of a Wi-Fi connection and you can share data from your VM to your host and vice versa.

In order to understand the following steps in a good way, please note that with host the Windows 8.1 is meant.

Step 1 is installing Client Hyper-V as this feature is not installed by default. First check if your notebook or desktop meets the necessary hardware and system requirements:

  • Windows 8.1 Pro or Enterprise 64 bit OS
  • 64-bit processor that has Second Level Address Translation (SLAT)
  • 4 GB of RAM
  • BIOS-level Hardware Virtualization support enabled

If all is good you are ready to go.

1) Open up a PowerShell window with administrator permissions on your host and run the following command

enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V –All

2) Type “Y” to restart your computer

clip_image002

clip_image004

Since I’m working on my notebook I want to use my onboard wireless adapter to get the VM connected to the Internet. Client Hyper-V can’t automatically use your Wi-Fi adapter so you need to use a little workaround to get this working. Therefore I will create two internal virtual switches in the next step. One is to use your wireless card and the other one will be used in a later step to share data between your host and your VM.

3) Open up PowerShell again with administrator permissions and run the following commands:

New-VMSwitch -Name InternalWifi -SwitchType Internal -Notes 'Share Parent Wifi'
New-VMSwitch -Name InternalShare -SwitchType Internal -Notes 'Sharing network'

image

4) You can check if both are created correctly by opening up your Hyper-V Manager and click on Virtual Switch Manager

image

5) Next open Network and Sharing Center on the host and choose Change adapter settings

6) Select the Wi-Fi adapter and choose Properties

clip_image010

7) In the Properties window, click the Sharing tab

8) Check the “Allow other network user to connect through this computer’s Internet connection” box, select “vEthernet (InternalWifi)” and click OK to close the window

clip_image012

9) If all is setup correctly you should see the word Shared beside your wireless connection

clip_image014

10) Run the below PowerShell script for an automated built of the W10 VM with all necessary virtual hardware installed and configured. Also the W10 ISO is connected and the VM will be started up to install the OS. It might be possible that you need the change some variables like the location and name of the ISO while running this script. 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: 14/04/15
#Name: BuiltW10VM.ps1
#Version: 1.0
#Note: Change variables were needed to fit your environment
#-------------------------------------------------------------------

# Variables
$VM = "W10-TST" # Name of 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 = 40GB # 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

# Create VM
New-VHD –Path $VMLOC\$VM\$VM.vhdx –Fixed –SizeBytes $VHDSIZE
New-VM –Name $VM –Path $VMLOC
Add-VMHardDiskDrive -VMName $VM -Path $VMLOC\$VM\$VM.vhdx
Set-VMMemory $VM -DynamicMemoryEnabled $true -MinimumBytes $VMRAMMIN -StartupBytes $VMRAMSTARTUP -MaximumBytes $VMRAMMAX -Priority 80 -Buffer 25
Set-VMProcessor $VM –Count $vCPUCOUNT

# Add Networks
Get-VMNetworkAdapter $VM| Connect-VMNetworkAdapter –SwitchName $NetworkSwitch2
Get-VM $VM | Add-VMNetworkAdapter -IsLegacy $true -SwitchName $NetworkSwitch1

# Mount ISO
Set-VMDvdDrive -VMName $VM -Path $W10ISO

Start-VM $VM

image

11) Install the guest OS and if all went good, logon for the first time to your WTP of W10

12) When logged on, rename the computer with the following PowerShell commands (requires admin rights)

Rename-Computer –NewName “W10-TST”
Restart-Computer

13) When the VM is restarted, logon and rename the network adapters via PowerShell (requires admin rights)

Get-NetAdapter -Name Ethernet | Rename-NetAdapter -NewName WiFi –PassThru
Get-NetAdapter -Name “Ethernet 2” | Rename-NetAdapter -NewName Sharing –PassThru

image

14) Assign the fixed IP Address 33.0.0.2 for the “Sharing” network adapter with use of PowerShell (requires admin rights) on the VM

#Retrieve the right network adapter
$netadapter = Get-NetAdapter -Name Sharing

#Disable DHCP
$netadapter | Set-NetIPInterface -DHCP Disabled

# Configure the IP addres
$netadapter | New-NetIPAddress -AddressFamily IPv4 -IPAddress 33.0.0.2 -PrefixLength 24 -Type Unicast

image

15) You can check if the IP Address is set correctly by running ipconfig

image

16) Now on the host, assign the static IP address 33.0.0.100 to the network adapter that was created for the virtual switch “InternalShare”. Open up PowerShell (requires admin rights) and run following commands

#Retrieve the right network adapter
$netadapter = Get-NetAdapter -Name “vEthernet (InternalShare)”

#Disable DHCP
$netadapter | Set-NetIPInterface -DHCP Disabled

# Configure the IP addres
$netadapter | New-NetIPAddress -AddressFamily IPv4 -IPAddress 33.0.0.100 -PrefixLength 24 -Type Unicast

image

17) To share and to create the Temp folder on the VM do the following:

#Create the Temp folder on the C-drive
New-Item -Path C:\Temp -ItemType directory

#Share the Temp folder
New-SmbShare -Name Temp -Path c:\Temp –FullAccess “EVERYONE”

image

18) To map the Temp folder from the VM on the host to the Z-drive run the following command in PowerShell (do not run PowerShell as an administrator)

New-PSDrive –Name Z –PSProvider FileSystem –Root “\\W10-TST\Temp” –Persist -Credential W10-TST\username

image

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

image

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

Wim Matthyssen (@wmatthyssen)