Real World Solutions

Here are a few problems and solutions that you might encounter when installing a new Windows Server 2012 Hyper-V.

Challenge

You have been asked to install a few Hyper-V hosts, but your deployment tool of choice is not yet ready? And of course the idea is to have all hosts configured identically.

Solution

This solution is going to use a PowerShell script and a XML file containing all required information. The script will take care on the install the required roles and features as well as configure the Hyper-V role. The script of course would have to get tuned and adopted to work in your environment. Please note there is no error handling or logging added.

The XML file could look like the following:

<?xml version=”1.0” encoding=”utf-8”?>
<Config>
  <Host>
    <Computer Name=”HYPERV21” Domain=”server-talk.eu” WinSysLocal=”en-US” />
    <VMHost VirtualMachinePath=”C:VMs” VirtualHardDiskPath=”C:VMs” MacAddressMinimum=”00-15-5D-78-21-00” MacAddressMaximum=”00-15-5D-78-21-FF” />	
  </Host>
  <Network>
    <Teaming Name=”Network Team” TeamMember1=”00-17-A4-77-00-2B” TeamMember2=”00-17-A4-77-00-2D”/>
    <VirtualSwitch Name=”Public Network” BW=”10” NetVirtDriver=”true” />
  </Network>
  <NetworkAdapter>
	<PubMgmt Name=”Public_Mgmt” IP=”192.168.1.21” SubnetPrefix=”24” Gateway=”192.168.1.1” DNS1=”192.168.1.101” DNS2=”192.168.1.102” VLAN=”” BW=”5” />
	<PrivMigration Name=”Private_Migration” IP=”10.10.10.21” SubnetPrefix=”24” VLAN=”” BW=”30” />
	<PrivCluster Name=”Private_Cluster” IP=”10.10.11.21” SubnetPrefix=”24” VLAN=”” BW=”20” />
	<General DisableDisconnected=”true” />
  </NetworkAdapter>
</Config>

Where the PowerShell script would look like this:

# ----------------------------------------------------------------------------------------------------
# Declare and define global variables
# ----------------------------------------------------------------------------------------------------
# Get XML Information
[XML]$ConfigXML = Get-Content “.HostConfigFile.xml”
# Host OS Settings
$strComputerName = $ConfigXML.Config.Host.Computer.Name
$strComputerDomain = $ConfigXML.Config.Host.Computer.Domain
$strComputerWinSysLocal = $ConfigXML.Config.Host.Computer.WinSysLocal
# Hyper-V Settings (VM Host)
$strVirtualMachinePath = $ConfigXML.Config.Host.VMHost.VirtualMachinePath
$strVirtualHardDiskPath = $ConfigXML.Config.Host.VMHost.VirtualHardDiskPath
$strMacAddressMinimum = $ConfigXML.Config.Host.VMHost.MacAddressMinimum
$strMacAddressMaximum = $ConfigXML.Config.Host.VMHost.MacAddressMaximum
# Network Settings
$strNetworkTeamName = $ConfigXML.Config.Network.Teaming.Name
$strNetworkTeamMember1 = $ConfigXML.Config.Network.Teaming.TeamMember1
$strNetworkTeamMember2 = $ConfigXML.Config.Network.Teaming.TeamMember2
$strVirtualSwitchName = $ConfigXML.Config.Network.VirtualSwitch.Name
$strVirtualSwitchBW = $ConfigXML.Config.Network.VirtualSwitch.BW
$strNetVirtDriver = $ConfigXML.Config.Network.VirtualSwitch.NetVirtDriver
# Network Adapter Configuration
$strNICNamePubMgmt = $ConfigXML.Config.NetworkAdapter.PubMgmt.Name
$strNICPubMgmtIP = $ConfigXML.Config.NetworkAdapter.PubMgmt.IP
$strNICPubMgmtSubnet = $ConfigXML.Config.NetworkAdapter.PubMgmt.SubnetPrefix
$strNICPubMgmtGW = $ConfigXML.Config.NetworkAdapter.PubMgmt.Gateway
$strNICPubMgmtDNS1 = $ConfigXML.Config.NetworkAdapter.PubMgmt.DNS1
$strNICPubMgmtDNS2 = $ConfigXML.Config.NetworkAdapter.PubMgmt.DNS2
$strNICPubMgmtVLAN = $ConfigXML.Config.NetworkAdapter.PubMgmt.VLAN
$strNICPubMgmtBW = $ConfigXML.Config.NetworkAdapter.PubMgmt.BW
$strNICNamePrivMigration = $ConfigXML.Config.NetworkAdapter.PrivMigration.Name
$strNICPrivMigrationIP = $ConfigXML.Config.NetworkAdapter.PrivMigration.IP
$strNICPrivMigrationSubnet = $ConfigXML.Config.NetworkAdapter.PrivMigration.SubnetPrefix
$strNICPrivMigrationVLAN = $ConfigXML.Config.NetworkAdapter.PrivMigration.VLAN
$strNICPrivMigrationBW = $ConfigXML.Config.NetworkAdapter.PrivMigration.BW
$strNICNamePrivCluster = $ConfigXML.Config.NetworkAdapter.PrivCluster.Name
$strNICPrivClusterIP = $ConfigXML.Config.NetworkAdapter.PrivCluster.IP
$strNICPrivClusterSubnet = $ConfigXML.Config.NetworkAdapter.PrivCluster.SubnetPrefix
$strNICPrivClusterVLAN = $ConfigXML.Config.NetworkAdapter.PrivCluster.VLAN
$strNICPrivClusterBW = $ConfigXML.Config.NetworkAdapter.PrivCluster.BW
$strNICDisconnected = $ConfigXML.Config.NetworkAdapter.General.DisableDisconnected
# Configure Operating System
# ----------------------------------------------------------------------------------------------------
Write-Output ‘Renaming computer’
Rename-Computer -NewName $strComputerName
Write-Output ‘Joining domain’
Add-Computer -DomainName $strComputerDomain
Write-Output ‘Changing Windows system local language’
Import-Module International
Set-WinSystemLocale -SystemLocale $strComputerWinSysLocal
# Install Hyper-V
# ----------------------------------------------------------------------------------------------------
Write-Output ‘Installing Multipath-IO Feature’
Add-WindowsFeature Multipath-IO
Write-Output ‘Installing Failover Cluster Feature’
Add-WindowsFeature Failover-Clustering -IncludeManagementTools
Write-Output ‘Installing Hyper-V Role’
Add-WindowsFeature Hyper-V -IncludeManagementTools -Restart
# Configure Classic Network
# ----------------------------------------------------------------------------------------------------
Write-Output ‘Creating network team’
Get-NetAdapter -Physical | Where-Object {$_.MacAddress -eq $strNetworkTeamMember1} | Rename-NetAdapter -NewName “Converged Team (Adapter 1)”
Get-NetAdapter -Physical | Where-Object {$_.MacAddress -eq $strNetworkTeamMember2} | Rename-NetAdapter -NewName “Converged Team (Adapter 2)”
$strNetworkTeamMembers = Get-NetAdapter -Physical | Where-Object {$_.Name -like “Converged Team (Adapter *” }
New-NetLbfoTeam -Name $strNetworkTeamName -TeamMembers $strNetworkTeamMembers.Name -TeamingMode SwitchIndependent -LoadBalancingAlgorithm TransportPorts
If ($strNICDisconnected -eq “true”) {
  Write-Output ‘Disabling disconnected network adapters’
  Get-NetAdapter -Physical | Where-Object {$_.Status -eq “Disconnected” } | Disable-NetAdapter }
Write-Output ‘Creating a new virtual Switch with one default virtual port for parent partition’
New-VMSwitch -Name $strVirtualSwitchName -MinimumBandwidthMode weight -NetAdapterName $strNetworkTeamName
Write-Output ‘Renaming the virtual port for the parent partition’
Rename-VMNetworkAdapter -ManagementOS -Name $strVirtualSwitchName -NewName $strNICNamePubMgmt
Write-Output ‘Creating addional virtual ports for the parent partition’
Add-VMNetworkAdapter -ManagementOS -Name $strNICNamePrivMigration -SwitchName $strVirtualSwitchName
Add-VMNetworkAdapter -ManagementOS -Name $strNICNamePrivCluster -SwitchName $strVirtualSwitchName
Write-Output ‘Assigning the default Virtual Port to a VLAN’
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $strNICNamePubMgmt -Access -VlanId $strNICPubMgmtVLAN
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $strNICNamePrivMigration -Access -VlanId $strNICPrivMigrationVLAN
Set-VMNetworkAdapterVlan -ManagementOS -VMNetworkAdapterName $strNICNamePrivCluster -Access -VlanId $strNICPrivClusterVLAN
Write-Output ‘Assigning IPv4 addresses to virtual ports in parent partition’
New-NetIPAddress -IPAddress $strNICPubMgmtIP -InterfaceAlias “vEthernet ($strNICNamePubMgmt)” -PrefixLength $strNICPubMgmtSubnet -DefaultGateway $strNICPubMgmtGW
New-NetIPAddress -IPAddress $strNICPrivMigrationIP -InterfaceAlias “vEthernet ($strNICNamePrivMigration)” -PrefixLength $strNICPrivMigrationSubnet
New-NetIPAddress -IPAddress $strNICPrivClusterIP -InterfaceAlias “vEthernet ($strNICNamePrivCluster)” -PrefixLength $strNICPrivClusterSubnet
Write-Output ‘Assigning DNS Server for virtual ports in parent partition’
Set-DnsClientServerAddress -InterfaceAlias “vEthernet ($strNICNamePubMgmt)” -ServerAddresses $strNICPubMgmtDNS1, $strNICPubMgmtDNS2
Write-Output ‘Disable DNS registration for private network adapters’
$strVNICNamingPrivMigration = “vEthernet (“ + $strNICNamePrivMigration + “)”
Set-DnsClient -InterfaceAlias $strVNICNamingPrivMigration -RegisterThisConnectionsAddress $false
$strVNICNamingPrivCluster = “vEthernet (“ + $strNICNamePrivCluster + “)”
Set-DnsClient -InterfaceAlias $strVNICNamingPrivCluster  -RegisterThisConnectionsAddress $false
Write-Output ‘Assigning Minimum Bandwidth to ports’
Set-VMNetworkAdapter -ManagementOS -Name $strNICNamePubMgmt -MinimumBandwidthWeight $strNICPubMgmtBW
Set-VMNetworkAdapter -ManagementOS -Name $strNICNamePrivMigration -MinimumBandwidthWeight $strNICPrivMigrationBW
Set-VMNetworkAdapter -ManagementOS -Name $strNICNamePrivCluster -MinimumBandwidthWeight $strNICPrivClusterBW
Set-VMSwitch $strVirtualSwitchName -DefaultFlowMinimumBandwidthWeight $strVirtualSwitchBW
If ($strNetVirtDriver -eq “true”) {
  Write-Output ‘Enabling Windows Network Virtualization Filter Driver’
  Enable-NetAdapterBinding -Name $strNetworkTeamName -ComponentID ms_netwnv
}
# Configure Hyper-V
# ----------------------------------------------------------------------------------------------------
Write-Output ‘Configuring Hyper-V Role’
Import-Module Hyper-V
Set-VMHost -VirtualMachinePath $strVirtualHardDiskPath -VirtualHardDiskPath $strVirtualMachinePath
Set-VMHost -MacAddressMinimum $strMacAddressMinimum  -MacAddressMaximum $strMacAddressMaximum
# Finish Installation / Configuration
# ----------------------------------------------------------------------------------------------------
Write-Output ‘Please restart computer to finish configuration’
#Restart-Computer

You don’t like typing? Check my blog (www.server-talk.eu) for a downloadable version of this script.

Challenge

You’ve installed a new Windows Server 2012 Hyper-V host and everything seemed to work fine, but then some issues with the storage appeared? As an example, an error in a clustered Hyper-V environment could be “Element not found (0x80070490)” when failover a clustered disk.

Solution

Have you checked if all hardware (and software) is certified for Windows Server 2012? Always make sure the host bus adapters (HBA) and especially the storage itself are using the latest firmware and driver and are listed in the Windows Server Catalog.

www.windowsservercatalog.com

Challenge

The installation of Windows Server 2012 stops with the error message “Windows cannot install required files. The file may be corrupt or missing. Make sure all files required for installation are available, and restart the installation. Error code: 0×80070570″. The only option is to confirm the error message, which then cancels the installation process.

Solution

This kind of problem occurs with corrupt installation media, for example ISO-Images which is the default media provided by Microsoft. Always make sure the MD5 or SHA1 value is correct compared to the one provided in the download portal. The download tool with the least failures would be the “Microsoft File Transfer Manager” or Akamai.

http://transfers.ds.microsoft.com/

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.90