You are browsing the archive for 2015 April.

Hyper-V Survey by Microsoft

10:51 am in Hyper-V by Wim Matthyssen

Hi all,

Microsoft is performing a small survey concerning Hyper-V. In this the Hyper-V team asks people to respond to a small number of questions. It just takes 5 to 10  minutes to complete.

You can find it via following link: https://www.instant.ly/s/G5bPn/nav#p/186a0

So if you have the time, please fill it in. The more responses they get, the more reliable the data will be.

hyperv

In the meanwhile keep tuned and I’ll be back soon.

Wim Matthyssen (@wmatthyssen)

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)

Hyper-V PowerShell – Determine which NIC is being used for CSV communication

4:35 pm in Hyper-V, PowerShell by Wim Matthyssen

image On a regular base I need to help customers with problems or changes on their Hyper-V environment. In those cases the quickest and most flexible way to do a lot of admin tasks is by use of PowerShell. Yes, it really can make your life as an IT administrator easier! So in this series I will provide you with the PowerShell commands that I mostly use when working on or troubleshooting Hyper-V environments.

When you first built your Hyper-V failover cluster and enable Cluster Shared Volumes (CSV), the network used for CSV communication and storage I/O redirection is automatically chosen. Keep in mind that it’s also the same network as for your cluster heartbeat. That’s why in part 1 of this series I will demonstrate, how you can quickly check which network is in use for this CSV communication. Secondly, I will explain how you can change that network manually.

1) First of all logon to a Hyper-V host and open up PowerShell with administrator permissions

2) Run the following command:

 Get-ClusterNetwork | ft Name, Metric, AutoMetric, Role 

image

The CSV communication network is always the network with the lowest metric, in this case the network with name “ClusterInterconnect” and a Metric of 1000. The reason for this is when the cluster sets the Metric, it always uses increments of 1000 for private networks (networks without a default gateway set) like the CSV network. So if you want to set it yourself, like I prefer, be sure to use a number smaller then 1000 and also make it the lowest metric value of all used networks. Myself I always use a Metric of 900, because then I’m completely sure that’s the case.

3) So to change the Metric setting to 900 for the CSV network, type the following command:

 (Get-ClusterNetwork "networkname").Metric = 900 

Be aware that if you set the Metric yourself the AutoMetric setting will change from True to False.

4) In case you want the cluster to start automatically assigning the Metric setting again, you need to run the following command:

 (Get-ClusterNetwork "networkname").AutoMetric = $true 

This concludes my first part of the Hyper-V PowerShell series. Keep tuned and more will follow!

Wim Matthyssen (@wmatthyssen)