• Shortcuts : 'n' next unread feed - 'p' previous unread feed • Styles : 1 2

» Publishers, Monetize your RSS feeds with FeedShow:  More infos  (Show/Hide Ads)


Date: Wednesday, 11 Jun 2014 16:24

If you follow me on Twitter (@HyperV_taylorb) this is old news but for those that don’t two updates for you…

Windows Server 2012 Security Guide For Hyper-V

http://technet.microsoft.com/en-us/library/dn741280.aspx

This release of the Hyper-V Security Guide consists of this Overview and chapters that discuss methods and best practices that will help you secure your Hyper-V environment. Brief descriptions follow for each chapter.

Chapter 1: Overview

This chapter provides necessary prerequisite information on Hyper-V to set the groundwork for subsequent material. In addition to the architecture of Hyper-V it also covers the administrator taxonomy in Hyper-V.

Chapter 2: Hardening the Hyper-V host

This chapter focuses on hardening servers that run the Hyper-V role of Windows Server 2012, in both Full and Server Core installations. It contains security best practice recommendations to help protect against unauthorized access and resource tampering.

Chapter 3: Roles & Delegation

This chapter covers details on delegation of access to resources. Additionally, it includes guidance on effective delegation of administrative roles to ensure security.

Chapter 4: Protecting Virtual Machines

This chapter provides prescriptive guidance for securing virtual machine resources. It discusses best practices and includes detailed steps for protecting virtual machines by using a combination of file system permissions, encryption, and auditing. Also included are resources for hardening and updating the operating system instances running within your virtual machines.

Chapter 5: Best Practices Checklist

The chapter covers recommended best practices that help enhance the security of a Hyper-V deployment.

QFE Released for Hyper-V Backup Failures When Utilizing the CSV Writer on Windows Server 2012 R2

Title:               Backing up virtual machines fails when using the CSV writer after installation of update 2919355 in Windows
KB Number:  2966407
URL:               http://support.microsoft.com/kb/2966407

This QFE only effects folks with backup solutions that leverage the cluster shared volume writer on Windows Server 2012 R2 after installing the April update (KB2919355).

-taylorb

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 20 May 2014 18:04

I’ve finally joined the world of Twitter…  Send me a Tweet @HyperV_taylorb or follow me https://twitter.com/HyperV_taylorb.

-taylorb

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 20 May 2014 17:59

Last week was TechEd 2014 in Houston, if you haven’t been to TechEd before it’s quite an experience.  This was a great year and we have some excellent sessions that where recorded and now published online.

Starting Page for All Sessions

http://channel9.msdn.com/Events/TechEd/NorthAmerica/2014

   

Sessions I Presented

Converged Networking for Windows Server 2012 R2 Hyper-V

Building a Backup Strategy for Your Private Cloud

   

Other Sessions I Recommend

File Server Networking for a Private Cloud Storage Infrastructure in Windows Server 2012 R2

Migrating to Hyper-V Using the Microsoft Virtual Machine Converter Tool

Secure Design and Best Practices for Your Private Cloud

Extend Datacenter Networking with Partner Solutions

-taylorb

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 12 Mar 2014 22:17

I have had a few folks ask me about importing VM’s though our WMI namespace.  The Hyper-V WMI v2 interfaces introduce a new concept of planned virtual machines, this  allows you to create/import virtual machines and make configuration changes prior to realizing them or converting them to real virtual machines that can be started or are even visible in the UI.

I have two samples below, the first one simply imports a VM and the second renames the VM as part of the import.  You can get more information about the ImportSystemDefinition API at http://msdn.microsoft.com/en-us/library/hh850082(v=vs.85).aspx.  We also have some additional samples utilizing planned virtual machines in our common sample code at http://msdn.microsoft.com/en-us/library/hh850032(v=vs.85).aspx.

Importing a VM

#Retrieve the management service
$VmMgmtSvc = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService

#Import the VM, referencing the VM configuration, snapshot folder
$ImportedSystem_ret = $VmMgmtSvc.ImportSystemDefinition(
    "D:\Demo\Virtual Machines\1B3CDA1D-6FB6-4AAE-8E8D-8BE6BB587BD3.XML",
    "D:\Demo\Snapshots",
    $false) #Retaining the VM id

#Retrieve the object referencing the planned VM
$PlannedVM = [WMI]$ImportedSystem_ret.ImportedSystem

#Realize the planned VM
$VmMgmtSvc.RealizePlannedSystem($PlannedVM)

Modifying a VM as part of import

#Retrieve the management service
$VmMgmtSvc = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService

#Import the VM, referencing the VM configuration, snapshot folder
$ImportedSystem_ret = $VmMgmtSvc.ImportSystemDefinition(
    "D:\Demo\Virtual Machines\1B3CDA1D-6FB6-4AAE-8E8D-8BE6BB587BD3.XML",
    "D:\Demo\Snapshots",
    $false) #Retaining the VM id

#Retrieve the object referencing the planned VM
$PlannedVM = [WMi]$ImportedSystem_ret.ImportedSystem

#Retrieve the setting data for the planned VM
$VmSetData = ($PlannedVM.GetRelated("Msvm_VirtualSystemSettingData", `
      "Msvm_SettingsDefineState", `
      $null, `
      $null, `
      "SettingData", `
      "ManagedElement", `
      $false, $null) | % {$_})

#Modify the name of the VM
$VmSetData.ElementName = "NewVMName"
$VmMgmtSvc.ModifySystemSettings($VmSetData.GetText(2))

#Realize the planned VM
$VmMgmtSvc.RealizePlannedSystem($PlannedVM)

-Taylorb

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Friday, 08 Nov 2013 20:46

I have gotten a few questions specifically regarding how to configure dynamic memory utilizing the root\virtualization\v2 namespace.  At face value it’s pretty simple you retrieve the Msvm_MemorySettingsData set the DynamicMemoryEnabled property to true, configure the startup (virtual quantity), minimum (reservation) and maximum (limit) properties and execute the ModifyResourceSettings method.  However if you just do those steps it will almost always fail – looking at the error it generally we be “Dynamic memory and virtual NUMA cannot be enabled on the virtual machine '<vm name>' because the features are mutually exclusive.”.  In the Hyper-V UI as well as PowerShell we take care of disabling and enabling virtual NUMA automatically when we disable or enable dynamic memory – your code should do the same.  Below is an example:

$vmName = "Template"

 #Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class. 
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService 

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'" 

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState", `
      $null, `
      $null, ` 
     "SettingData", `
     "ManagedElement", `
      $false, $null) | % {$_}) 

#Retrieve the Msvm_MemorySettingData Associated to the VM. 
$Msvm_MemorySettingData = ($Msvm_VirtualSystemSettingData.GetRelated( "Msvm_MemorySettingData") | % {$_})

#Enable Dynamic Memory
$Msvm_MemorySettingData.DynamicMemoryEnabled = $true

#Dynamic Memory and Virtual NUMA can not be enabled at the same time
if ($Msvm_MemorySettingData.DynamicMemoryEnabled)
{
    $Msvm_VirtualSystemSettingData.VirtualNumaEnabled = $false

    #Reservation is equavilant to minimum memory
    $Msvm_MemorySettingData.Reservation = 1024

    #VirtualQuantity is equavilant to startup memory
    $Msvm_MemorySettingData.VirtualQuantity = 2048

    #Limit is equivalnt to Maximum Memory
    $Msvm_MemorySettingData.Limit = 8096
}
else
{
    $Msvm_VirtualSystemSettingData.VirtualNumaEnabled = $true
    
    #VirtualQuantity is the static allocation amount
    $Msvm_MemorySettingData.VirtualQuantity = 4096
}

#First apply the Virtual NUMA changes then Apply The Memory Changes
$Msvm_VirtualSystemManagementService.ModifySystemSettings($Msvm_VirtualSystemSettingData.GetText(2))
$Msvm_VirtualSystemManagementService.ModifyResourceSettings($Msvm_MemorySettingData.GetText(2))

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 24 Sep 2013 16:20

The Exchange team has just released a new white paper on virtualizing Exchange 2013, it’s over 90 pages and goes into pretty good detail – if your virtualizing Exchange or plan to going forward I’d spend some time going over it.

 

Best Practices for Virtualizing & Managing Exchange 2013

 

-taylorb

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 12 Aug 2013 19:02

What good would Attaching a VHD To A VM Using The Hyper-V WMI V2 Namespace be if you couldn’t remove one two… Here’s how you do it.

 

Removing a virtual hard disk

$vmName = "Test" 
$vhdPath = "d:\vms\Test.vhdx"

#Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class. 
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService 

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'" 

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState", `
      $null, `
      $null, ` 
     "SettingData", `
     "ManagedElement", `
      $false, $null) | % {$_}) 

#Find the VirtualDisk with the path specified
$virtualHardDisk = $Msvm_VirtualSystemSettingData.GetRelated("Msvm_StorageAllocationSettingData") | Where-Object {
    ($_.HostResource -contains $vhdPath)} 

#Save the associated Disk Drive
$SyntheticDiskDrive = [WMI]$virtualHardDisk.Parent

#Call the RemoveResourceSettings function with the path to virtual hard disk
$Msvm_VirtualSystemManagementService.RemoveResourceSettings($virtualHardDisk)

#Call the RemoveResourceSettings function with the path to disk drive
$Msvm_VirtualSystemManagementService.RemoveResourceSettings($SyntheticDiskDrive)

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 12 Aug 2013 18:51

Relating to all my recent posts on the WMI V2 namespace here’s another one for attaching a VHD to a VM.  It looks like a lot of code but a lot of it is duplicated (so if you where writing an application you can factor it pretty easily).  There are effectively two steps to this process, the first is to add a synthetic disk drive and the second is to connect that disk drive to the actual VHD.

 

Attaching A VHD To A VM

$vmName = "Test" 
$vhdPath = "d:\vms\Test.vhdx"

 #Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class. 
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService 

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'" 

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState", `
      $null, `
      $null, ` 
     "SettingData", `
     "ManagedElement", `
      $false, $null) | % {$_}) 


#Retrieve the default (primordial) resource pool for Synthetic Disk Drive’s
$Msvm_ResourcePool = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ResourcePool `
    -Filter "ResourceSubType = 'Microsoft:Hyper-V:Synthetic Disk Drive' and Primordial = True"

#Retrieve the AllocationCapabilities class for the Resource Pool
$Msvm_AllocationCapabilities = ($Msvm_ResourcePool.GetRelated("Msvm_AllocationCapabilities", `
    "Msvm_ElementCapabilities", `
    $null, `
    $null, `
    $null, `
    $null, `
    $false, `
    $null) | % {$_})

#Query the relationships on the AllocationCapabilities class and find the default class (ValueRole = 0)
$Msvm_SettingsDefineCapabilities = ($Msvm_AllocationCapabilities.GetRelationships(`
    "Msvm_SettingsDefineCapabilities") | Where-Object {$_.ValueRole -eq "0"})

#The PartComponent is the Default Msvm_StorageAllocationSettingData class values
$Msvm_StorageAllocationSettingDataTemplate = [WMI]$Msvm_SettingsDefineCapabilities.PartComponent

#Clone the default settings
$Msvm_StorageAllocationSettingData = $Msvm_StorageAllocationSettingDataTemplate.Clone()

#Find the IDE Controller To Connect The Disk To 
$IdeController = $Msvm_VirtualSystemSettingData.GetRelated("Msvm_ResourceAllocationSettingData") | Where-Object {
    ($_.ResourceType -eq 5) -and ($_.ResourceSubType -eq "Microsoft:Hyper-V:Emulated IDE Controller") -and ($_.Address -eq 0)} 

#Specify the disk drives connection point and address (location on the controller)
$Msvm_StorageAllocationSettingData.Parent = $IdeController
$Msvm_StorageAllocationSettingData.AddressOnParent = 0

#Add the drive to the VM and save the resulting disk drive path
$diskDriveResource = ($Msvm_VirtualSystemManagementService.AddResourceSettings($Msvm_VirtualSystemSettingData, `
    $Msvm_StorageAllocationSettingData.GetText(2)).ResultingResourceSettings)


#Retrieve the default (primordial) resource pool for Virtual Hard Disk’s
$Msvm_ResourcePool = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ResourcePool `
    -Filter "ResourceSubType = 'Microsoft:Hyper-V:Virtual Hard Disk' and Primordial = True"

#Retrieve the AllocationCapabilities class for the Resource Pool
$Msvm_AllocationCapabilities = ($Msvm_ResourcePool.GetRelated("Msvm_AllocationCapabilities", `
    "Msvm_ElementCapabilities", `
    $null, `
    $null, `
    $null, `
    $null, `
    $false, `
    $null) | % {$_})

#Query the relationships on the AllocationCapabilities class and find the default class (ValueRole = 0)
$Msvm_SettingsDefineCapabilities = ($Msvm_AllocationCapabilities.GetRelationships(`
    "Msvm_SettingsDefineCapabilities") | Where-Object {$_.ValueRole -eq "0"})

#The PartComponent is the Default Msvm_StorageAllocationSettingData class values
$Msvm_StorageAllocationSettingDataTemplate = [WMI]$Msvm_SettingsDefineCapabilities.PartComponent

#Clone the default settings
$Msvm_StorageAllocationSettingData = $Msvm_StorageAllocationSettingDataTemplate.Clone()

#Specify the VHD's Disk Drive and Path (location on the controller)
$Msvm_StorageAllocationSettingData.Parent = $diskDriveResource
$Msvm_StorageAllocationSettingData.HostResource = @($vhdPath)

#Add the VHD to the disk drive
$Msvm_VirtualSystemManagementService.AddResourceSettings($Msvm_VirtualSystemSettingData, `
    $Msvm_StorageAllocationSettingData.GetText(2))

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 12 Aug 2013 17:18

Relating to my previous posts regarding Adding a Network Adapter To A VM Using The Hyper-V WMI V2 Namespace and Connecting a VM Network Adapter To A Switch Using The Hyper-V WMI V2 Namespace I had some questions come in around removing a NIC.  So here’s a sample – it’s pretty simple…

 

Removing a NIC

$vmName = "Test" 

 #Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class. 
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService 

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'" 

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState", `
      $null, `
      $null, ` 
     "SettingData", `
     "ManagedElement", `
      $false, $null) | % {$_}) 


#Retrieve the NetworkAdapterPortSettings Associated to the VM. 
$Msvm_SyntheticEthernetPortSettingData = ($Msvm_VirtualSystemSettingData.GetRelated(` 
     "Msvm_SyntheticEthernetPortSettingData") `
      | Where-Object {$_.ElementName -eq "Network Adapter"}) 

#Call the RemoveResourceSettings function with the path to network adapater
$Msvm_VirtualSystemManagementService.RemoveResourceSettings($Msvm_SyntheticEthernetPortSettingData)

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 12 Aug 2013 16:51

Relating to my previous posts regarding Adding a Network Adapter To A VM Using The Hyper-V WMI V2 Namespace and Connecting a VM Network Adapter To A Switch Using The Hyper-V WMI V2 Namespace I had some questions come in around configuring static vs dynamic MAC addresses.  So here’s some samples – you will notice they are identical except for setting the StaticMacAddress and Address properties.

 

Changing The MAC Address To Static

$vmName = "Test" 

 #Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class. 
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService 

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'" 

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState", `
      $null, `
      $null, ` 
     "SettingData", `
     "ManagedElement", `
      $false, $null) | % {$_}) 


#Retrieve the NetworkAdapterPortSettings Associated to the VM. 
$Msvm_SyntheticEthernetPortSettingData = ($Msvm_VirtualSystemSettingData.GetRelated(` 
     "Msvm_SyntheticEthernetPortSettingData") `
      | Where-Object {$_.ElementName -eq "Network Adapter"}) 

#Set the Static Mac Address To True and the Address to the MAC for the NIC
$Msvm_SyntheticEthernetPortSettingData.StaticMacAddress = $true
$Msvm_SyntheticEthernetPortSettingData.Address = "0003FF123456"

$Msvm_VirtualSystemManagementService.ModifyResourceSettings($Msvm_SyntheticEthernetPortSettingData.GetText(2))

 

Changing The MAC Address To Dynamic

$vmName = "Test" 

 #Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class. 
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_VirtualSystemManagementService 

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
      -Class Msvm_ComputerSystem -Filter "ElementName='$vmName'" 

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState", `
      $null, `
      $null, ` 
     "SettingData", `
     "ManagedElement", `
      $false, $null) | % {$_}) 


#Retrieve the NetworkAdapterPortSettings Associated to the VM. 
$Msvm_SyntheticEthernetPortSettingData = ($Msvm_VirtualSystemSettingData.GetRelated(` 
     "Msvm_SyntheticEthernetPortSettingData") `
      | Where-Object {$_.ElementName -eq "Network Adapter"}) 

#Set the Static Mac Address To False and the Address to an Empty String
$Msvm_SyntheticEthernetPortSettingData.StaticMacAddress = $false
$Msvm_SyntheticEthernetPortSettingData.Address = ""

$Msvm_VirtualSystemManagementService.ModifyResourceSettings($Msvm_SyntheticEthernetPortSettingData.GetText(2))

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 15 Jul 2013 18:34

Following along with Adding a Network Adapter To A VM Using The Hyper-V WMI V2 Namespace you might want to connect a network adapter to a switch…  Here’s how you would that, one thing to comment on is that the object returned when calling AddResourceSettings from the previous example is the Msvm_SyntheticEthernetPortSettingData class – which means you can skip about the first half of this code…

$vmName = "Test"
$switchName = "Demo"

#Retrieve the Hyper-V Management Service, ComputerSystem class for the VM and the VM’s SettingData class.
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 ` 
     
-Class Msvm_VirtualSystemManagementService

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 `
     
-Class Msvm_ComputerSystem -Filter "ElementName='$vmName'"

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
     "Msvm_SettingsDefineState"
, `
     
$null, `
     
$null, `
     "SettingData"
, `
     "ManagedElement"
, `
     
$false, $null) | % {$_})

#Retrieve the VirtualSwitch class the NIC will Connect to
$Msvm_VirtualEthernetSwitch = Get-WmiObject -Namespace root\virtualization\v2 `
     
-Class Msvm_VirtualEthernetSwitch -Filter "ElementName='$switchName'"

#Retrieve the NetworkAdapterPortSettings Associated to the VM.
$Msvm_SyntheticEthernetPortSettingData = ($Msvm_VirtualSystemSettingData.GetRelated(`
     "Msvm_SyntheticEthernetPortSettingData"
) `
     
| Where-Object {$_.ElementName -eq "Network Adapter"})

#Retrieve the default (primordial) resource pool for the Ethernet Connection
$Msvm_ResourcePool = (Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ResourcePool `
     
-Filter "ResourceSubType = 'Microsoft:Hyper-V:Ethernet Connection' and Primordial = True" | % {$_})

#Retrieve the AllocationCapabilities class for the Resource Pool
$Msvm_AllocationCapabilities = ($Msvm_ResourcePool.GetRelated("Msvm_AllocationCapabilities", `
     "Msvm_ElementCapabilities"
, `
     
$null, `
     
$null, `
     
$null, `
     
$null, `
     
$false, `
     
$null) | % {$_})

#Query the relationships on the AllocationCapabilities class and find the default class (ValueRole = 0)
$Msvm_SettingsDefineCapabilities = ($Msvm_AllocationCapabilities.GetRelationships(`
     "Msvm_SettingsDefineCapabilities"
) | Where-Object {$_.ValueRole -eq "0"})

#The PartComponent is the Default SyntheticEthernetPortSettingData class values
$Msvm_EthernetPortAllocationSettingData = [WMI]$Msvm_SettingsDefineCapabilities.PartComponent

#Specify the NIC's Port Setting and the Switch Path
$Msvm_EthernetPortAllocationSettingData.Parent = $Msvm_SyntheticEthernetPortSettingData
$Msvm_EthernetPortAllocationSettingData.HostResource = $Msvm_VirtualEthernetSwitch


#Add the connection object which connects the NIC
$Msvm_VirtualSystemManagementService.AddResourceSettings($Msvm_VirtualSystemSettingData, $Msvm_EthernetPortAllocationSettingData.GetText(2))

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 15 Jul 2013 18:17
I have had a number of folks ask how to utilize the root\virtualization\v2 namespace to add a network adapter to a VM… 
 
For some more information take a look at the following MSDN pages: Networking service, Sample: Querying networking objects.
 

 

$vmName = "Test"

#Retrieve the Hyper-V Management Service, The ComputerSystem class for the VM and the VM’s SettingData class.
$Msvm_VirtualSystemManagementService = Get-WmiObject -Namespace root\virtualization\v2 ` 
     
-Class Msvm_VirtualSystemManagementService

$Msvm_ComputerSystem = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ComputerSystem `
     
-Filter "ElementName='$vmName'"

$Msvm_VirtualSystemSettingData = ($Msvm_ComputerSystem.GetRelated("Msvm_VirtualSystemSettingData", `
      "Msvm_SettingsDefineState"
, `
     
$null, `
     
$null, `
      "SettingData"
, `
      "ManagedElement"
, `
     
$false, $null) | % {$_})

#Retrieve the default (primordial) resource pool for Synthetic Ethernet Port’s
$Msvm_ResourcePool = Get-WmiObject -Namespace root\virtualization\v2 -Class Msvm_ResourcePool `
     
-Filter "ResourceSubType = 'Microsoft:Hyper-V:Synthetic Ethernet Port' and Primordial = True"

#Retrieve the AllocationCapabilities class for the Resource Pool
$Msvm_AllocationCapabilities = ($Msvm_ResourcePool.GetRelated("Msvm_AllocationCapabilities", `
     "Msvm_ElementCapabilities"
, `
     
$null, `
     
$null, `
     
$null, `
     
$null, `
     
$false, `
     
$null) | % {$_})

#Query the relationships on the AllocationCapabilities class and find the default class (ValueRole = 0)
$Msvm_SettingsDefineCapabilities = ($Msvm_AllocationCapabilities.GetRelationships(`
     "Msvm_SettingsDefineCapabilities"
) | Where-Object {$_.ValueRole -eq "0"})

#The PartComponent is the Default SyntheticEthernetPortSettingData class values
$Msvm_SyntheticEthernetPortSettingData = [WMI]$Msvm_SettingsDefineCapabilities.PartComponent

#Specify a unique identifier, a friendly name and specify dynamic mac addresses
$Msvm_SyntheticEthernetPortSettingData.VirtualSystemIdentifiers = [Guid]::NewGuid().ToString("B")
$Msvm_SyntheticEthernetPortSettingData.ElementName = "Network Adapter"
$Msvm_SyntheticEthernetPortSettingData.StaticMacAddress = $false

#Add the network adapter to the VM
$Msvm_VirtualSystemManagementService.AddResourceSettings($Msvm_VirtualSystemSettingData, `
     
$Msvm_SyntheticEthernetPortSettingData.GetText(2))
 

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Tuesday, 09 Jul 2013 19:52

The July Windows Server 2012/Windows 8 update (KB2855336) contains two fixes for Hyper-V scenarios that are likely to be important to a number of customers.

 

Both of these updates are included in the rollup KB2855336.

 

KB2853952 - Loss of consistency with IDE-attached virtual hard disks when a Windows Server 2012-based Hyper-V host server experiences an unplanned restart (renamed from Active Directory database becomes corrupted when a Windows Server 2012-based Hyper-V host server crashes)

This issue effects virtualized active directory servers – in the event that the host crashes or looses power the active directory instance may become corrupted.  If this occurs on startup active directory will blue screen/bug check the virtual machine with an error of  “c00002e2 Directory Services could not start because of the following error:  %hs  Error Status: 0x%x.  Please shutdown this system and reboot into Directory Services Restore Mode, check the event log for more detailed information.”.  There may be additional roles or applications impacted by this issue as the underlying cause is that when a guest operating system requests the Hyper-V server to disable disk caching the wrong error is returned making the guest operating system believe that caching has been disabled when it has not.

This update should be installed on the Hyper-V host.

KB2854362 - Vmms.exe processes freeze on certain nodes in a Windows Server 2012-based Hyper-V failover cluster

This issue effects clustered Hyper-V servers with virtual machines hosted on a scale-out file server cluster.  In the event of a node failure that results in VM’s being failed over and brought online on other nodes the VMMS process on those nodes may freeze resulting in VM’s that remain in the offline state.

This update should be installed on all of the Hyper-V hosts within a cluster.

 

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 08 Jul 2013 21:50

I wanted to let everyone know the SQL Server team has just published a shiny new white paper (96 pages long) that discusses all the best practices for managing SQL Server on virtual machines in Windows Server 2012...  It's a very well done white paper and definitely worth reading.

Here's a link to it:Best Practices for Virtualizing and Managing SQL Server 2012

 

-Taylor Brown
-Program Manager, Hyper-V

 

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Monday, 06 May 2013 17:10

I got a few notes about my signature line on my previous post ‘Program Manager, Hyper-V’… Yep I am now a program manager on the Hyper-V team – I moved over from the Hyper-V test team a few weeks ago and now work on Ben Armstrong’s (virtual pc guy) team.  I have spent almost my entire career in test, over 11 years including over nine years on the virtualization team, first on Virtual PC then Virtual Server and most recently on Hyper-V.  I loved being a tester and the Hyper-V test team is among the best in the industry in my opinion but it was time for a new challenge.  Microsoft is an amazing company to work for with excellent managers that enabled me for many years to walk a line between the roles and responsibilities of a tester and those of a PM and over the past few years I’ve deviated further and further toward the PM side so this was a pretty natural move to make.  There aren’t many companies that allow you to craft your own role and facilitate your growth in that role for years, Microsoft is an amazing company to work for…

 

-Taylor Brown
-Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Thursday, 02 May 2013 16:51

Some folks have asked creating there own VMConnect application – it’s actually really easy.  Here’s a very basic example of how to create your own VMConnect application.  You would likely want to add some error handling, change the window sizing, maybe a WMI call to retrieve the name of the VM vs the ID but with Hyper-V’s WMI API you can do all of that and more after all now it’s your VMConnect application.

Steps To Create Basic Application

  1. Create a new C# Windows Forms project In Visual Studio
  2. Add a COM reference to mstscax.dll (Microsoft Terminal Service Active Client 1.0 Type Library)
  3. Add a new RDP Client Control to the form
    1. From the form designer right click in the toolbox and select Choose Toolbox Item
    2. Select COM Components and find and check “Microsoft RDP Client Control – version 9
    3. From All Windows Forms (generally at the bottom) find the “Microsoft RDP Client Control – version 9” option and drag it to the form
  4. Add a text box for the VM ID and a connect button to the form
  5. For the connect button’s click event specify the following basic code
private void ConnectButton_Click(object sender, EventArgs e)
{
    //specify the server the VM is running on
    axMsRdpClient8NotSafeForScripting1.Server = "localhost";

    //enable relative mouse mode and smart sizing
    axMsRdpClient8NotSafeForScripting1.AdvancedSettings7.RelativeMouseMode = true;
    axMsRdpClient8NotSafeForScripting1.AdvancedSettings7.SmartSizing = true;

    //specify the authentication service - this is required and set the authentication level
    axMsRdpClient8NotSafeForScripting1.AdvancedSettings7.AuthenticationServiceClass = 
        "Microsoft Virtual Console Service";
    axMsRdpClient8NotSafeForScripting1.AdvancedSettings6.AuthenticationLevel = 0;

    //retrieve the activeX control and enable CredSSP and disable NegotiateSecurity
    MSTSCLib.IMsRdpClientNonScriptable3 Ocx = 
        (MSTSCLib.IMsRdpClientNonScriptable3)axMsRdpClient8NotSafeForScripting1.GetOcx();
    Ocx.EnableCredSspSupport = true;
    Ocx.NegotiateSecurityLayer = false;

    //retrieve the activeX control and disable CredentialsDelegation
    MSTSCLib.IMsRdpExtendedSettings rdpExtendedSettings = 
        (MSTSCLib.IMsRdpExtendedSettings)axMsRdpClient8NotSafeForScripting1.GetOcx();
    object True = true;
    rdpExtendedSettings.set_Property("DisableCredentialsDelegation", ref True);

    //set the RDPPort and set the PCB string to the VM's ID
    axMsRdpClient8NotSafeForScripting1.AdvancedSettings2.RDPPort = 2179;
    axMsRdpClient8NotSafeForScripting1.AdvancedSettings7.PCB = vmIDTextBox.Text;

    //connect to the VM
    axMsRdpClient8NotSafeForScripting1.Connect();
}

 

Step 1 - Create a new C# Windows Forms project In Visual Studio
image

Step 2 - Add a COM reference to mstscax.dll (Microsoft Terminal Service Active Client 1.0 Type Library)
image

Step 3.1 - Add a new RDP Client Control to the form, From the form designer right click in the toolbox and select Choose Toolbox Item
image

Step 3.2 - Add a new RDP Client Control to the form, Select COM Components and find and check “Microsoft RDP Client Control – version 9
image

Step 3.2 - Add a new RDP Client Control to the form, From All Windows Forms (generally at the bottom) find the “Microsoft RDP Client Control – version 9” option and drag it to the form
image

 

Step 4 - Add a text box for the VM ID and a connect button to the form
image

Step 5 - For the connect button’s click event specify the following basic code
image

Your new solution in action!
image 

-taylorb
Program Manager, Hyper-V

Author: "Taylor Brown [MSFT]"
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 05 Dec 2012 20:51

I was reviewing my blog statistics the other day and noticed that a number of my old posts going all the way back to 2008 are still getting a lot of traffic.  A lot has changed since 2008 and while in most cases the information has stayed the same in many cases there are new or better ways to accomplish the same thing.  So over the next few weeks my goal is to update some of the old posts that still get a lot of traffic.  In some cases I will just edit the old post and add appropriate information – in other cases I will make a brand new post with new information and link between them.

Hopefully this is helpful to both the folks who stumble across the old posts as well as folks that read the new ones…

 

-taylorb

Author: "Taylor Brown [Microsoft Hyper-V]"
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 05 Dec 2012 20:46

This is effectively and update from one my very old posts Hyper-V WMI: KVP Exchange aka Data Exchange (Retrieving and Modifying Parent/Host KVP’s) which still receives a lot of traffic.  The same code from back in 2008 still works today even on Windows Server 2012 – however with Windows Server 2012 we have introduced a new version of our WMI API’s (WMI v2) and for future releases the old code may stop working as we have not committed to (or not to) supporting the old version 1 API’s.  In the case of the Msvm_KvpExchangeComponent class not much has changed – literally the only difference between the version 1 sample and version 2 sample below is the ‘\v2’ in the namespace, this is not true for most other components.

 

Adding/Modifying Key Value Pairs From A Guest

Adding values from within the guest is as simple as creating a new registry value under the HKLM\Software\Microsoft\Virtual Machine\Guest section of the registry.  You do have to be an administrator in the VM in order to access this section of the registry.  Retreating the value from the host or a remote machine with permissions on the host is just a WMI query away.

Adding A New Key Value Pair In The Guest

$regPath = "HKLM:\SOFTWARE\Microsoft\Virtual Machine\Guest“
Set-ItemProperty -Path $regPath -Name "Status" -Value “Ready" -Type String

Modifying the value is as easy as just changing the value above…

Reading The Value From The Host – Using WMI Version 2 Namespace

$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_ComputerSystem -Filter {ElementName = 'Vm1'}

$vm.GetRelated("Msvm_KvpExchangeComponent").GuestExchangeItems | % { `
    $GuestExchangeItemXml = ([XML]$_).SelectSingleNode(`
       
"/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child::text() = 'Status']")

    if ($GuestExchangeItemXml -ne $null)
    {
        $GuestExchangeItemXml.SelectSingleNode(`
            "/INSTANCE/PROPERTY[@NAME='Data']/VALUE/child::text()").Value
   
}
}

Reading The Value From The Host – Using WMI Version 1 Namespace

$vm = Get-WmiObject -Namespace root\virtualization -Class `
    Msvm_ComputerSystem -Filter {ElementName = 'Vm1'}

$vm.GetRelated("Msvm_KvpExchangeComponent").GuestExchangeItems | % { `
    $GuestExchangeItemXml = ([XML]$_).SelectSingleNode(`
       
"/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child::text() = 'Status']")

    if ($GuestExchangeItemXml -ne $null)
    {
        $GuestExchangeItemXml.SelectSingleNode(`
            "/INSTANCE/PROPERTY[@NAME='Data']/VALUE/child::text()").Value
   
}
}

Adding/Modifying Key Value Pairs From A Host

To add a key value pair from the host you must get the instance of the management service as well as the VM.  You must also create a new instance of the Msvm_KvpExchangeDataItem class – I build the path to this class using the instance of the management service such that if the script is running remotely it will connect to the right server.  Once you have the new instance of the class you just need to specify the Name, Data and Source parameters (source must be 0).  Then just call the AddKvpItems Method providing the instance of the VM and the instance of the created class.

Querying for key value pairs created from the host is very similar to ones from the guest except that you have to go though one more association to get to the Msvm_KvpExchangeComponentSettingsData class other than that it’s pretty much the same process.  Modifying and deleting values is almost the same as creating them – you just specify the same Key name as the value you wish to update/delete and call the Modify or Delete method.

Note that the example below utilizes the V2 namespace, if you are using Windows Server 2008 or R2 you can remove the \v2 and the script will work just fine.

Adding A New Key Value Pair

$VmMgmt = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_VirtualSystemManagementService

$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_ComputerSystem -Filter {ElementName='VM1'}

$kvpDataItem = ([WMIClass][String]::Format("\\{0}\{1}:{2}", `
    $VmMgmt.ClassPath.Server, `
    $VmMgmt.ClassPath.NamespacePath, `
    "Msvm_KvpExchangeDataItem")).CreateInstance()

$kvpDataItem.Name = "Name"
$kvpDataItem.Data = "Data"
$kvpDataItem.Source = 0

$VmMgmt.AddKvpItems($Vm, $kvpDataItem.PSBase.GetText(1))

Querying For Key Value Pairs In The Guest

$regPath = "HKLM:\SOFTWARE\Microsoft\Virtual Machine\External"
Get-ItemProperty -Path $regPath -Name "Name"

Querying For Key Value Pairs On The Host

$VmMgmt = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_VirtualSystemManagementService

$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_ComputerSystem -Filter {ElementName='VM1'}

($vm.GetRelated("Msvm_KvpExchangeComponent")[0] `
    ).GetRelated("Msvm_KvpExchangeComponentSettingData").HostExchangeItems | % { `
        $GuestExchangeItemXml = ([XML]$_).SelectSingleNode(`
            "/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child::text() = 'Name2']")
       
        if ($GuestExchangeItemXml -ne $null)
        {
      $GuestExchangeItemXml.SelectSingleNode(`
            "/INSTANCE/PROPERTY[@NAME='Data']/VALUE/child::text()").Value
        }   
    }

Modifying Key Value Pairs

$VmMgmt = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_VirtualSystemManagementService

$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_ComputerSystem -Filter {ElementName='VM1'}

$kvpDataItem = ([WMIClass][String]::Format("\\{0}\{1}:{2}", `
    $VmMgmt.ClassPath.Server, `
    $VmMgmt.ClassPath.NamespacePath, `
    "Msvm_KvpExchangeDataItem")).CreateInstance()

$kvpDataItem.Name = "Name"
$kvpDataItem.Data = "Data2"
$kvpDataItem.Source = 0

$VmMgmt.ModifyKvpItems($Vm, $kvpDataItem.PSBase.GetText(1))

Removing Key Value Pairs

$VmMgmt = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_VirtualSystemManagementService

$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_ComputerSystem -Filter {ElementName='VM1'}

$kvpDataItem = ([WMIClass][String]::Format("\\{0}\{1}:{2}", `
    $VmMgmt.ClassPath.Server, `
    $VmMgmt.ClassPath.NamespacePath, `
    "Msvm_KvpExchangeDataItem")).CreateInstance()

$kvpDataItem.Name = "Name"
$kvpDataItem.Data = [String]::Empty
$kvpDataItem.Source = 0


$VmMgmt.RemoveKvpItems($Vm, $kvpDataItem.PSBase.GetText(1))

 

-taylorb

Author: "Taylor Brown [Microsoft Hyper-V]"
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 05 Dec 2012 18:40

This post is to update an old from one 2008 Hyper-V WMI Using PowerShell Scripts – Part 3 (KVP's - Guest OS Version) – in reviewing that post the most coming inquiry was looking for the guests IP address, well we got that for you in PowerShell now…  With the introduction of Windows Server 2012 Hyper-V now includes 164 different PowerShell cmdlet’s.  On of those is Get-VMNetworkAdapter and one of the properties we included in that cmdlet is the IPAddress that network adapter has assigned to it.  We retrieve that information using the tried and true key value pair integration component.

PowerShell Example

PS C:\> (Get-VMNetworkAdapter -VMName VM1).IpAddresses
192.168.0.104
fe80::3114:f7d4:4561:9ea2
2001:1234:a:2:7891:f7d4:4561:9ea2

WMI Example Querying The Key Value Pair (KVP) Integration Component

$vm = Get-WmiObject -Namespace root\virtualization\v2 -Class `
    Msvm_ComputerSystem -Filter {ElementName='VM1'}

$vm.GetRelated("Msvm_KvpExchangeComponent").GuestIntrinsicExchangeItems | % { `
        $GuestExchangeItemXml = ([XML]$_).SelectSingleNode(`
            "/INSTANCE/PROPERTY[@NAME='Name']/VALUE[child::text()='NetworkAddressIPv4']")
       
        if ($GuestExchangeItemXml -ne $null)
        {
      $GuestExchangeItemXml.SelectSingleNode(`
            "/INSTANCE/PROPERTY[@NAME='Data']/VALUE/child::text()").Value
        }   
    }

Other Key Value Pair’s Provided

KVP Name Sample Value
FullyQualifiedDomainName vm1.contoso.com
OSName Windows Server 2008 R2 Enterprise
OSVersion 6.1.7601
CSDVersion Service Pack 1
OSMajorVersion 6
OSMinorVersion  1
OSBuildNumber 7601
OSPlatformId 2
ServicePackMajor 1
ServicePackMinor 0
SuiteMask 274
ProductType 3
OSVendor 1
OSSignature 4
OSEditionId 10
ProcessorArchitecture 9
IntegrationServicesVersion 6.2.9200.16433
NetworkAddressIPv4 192.168.0.123
NetworkAddressIPv6 fe80::3114:f7d4:4561:9ea2;2001:1234:a:2:7891:f7d4:4561:9ea2
RDPAddressIPv4 192.168.0.123
RDPAddressIPv6 fe80::3114:f7d4:4561:9ea2;2001:1234:a:2:7891:f7d4:4561:9ea2

 

-taylorb

Author: "Taylor Brown [Microsoft Hyper-V]"
Comments Send by mail Print  Save  Delicious 
Date: Wednesday, 07 Nov 2012 19:46

 

In my post yesterday (Remote Administration Without Constrained Delegation Using PrincipalsAllowedToDelegateToAccount) I showed how to utilize the new resource-based Kerberos constrained delegation to configure remote administration with Hyper-V over SMB.  The other place that Hyper-V requires constrained delegation for remote management is for standalone live migration as well as for storage migration.  The good news is that that the same functionality works for these scenarios as well.

Basic Configuration

In this example below we are just getting the active directory computer object for the destination Hyper-V server and then setting the PrincipalsAllowedToDelegateToAccount with the active directory computer object of the source Hyper-V server.  In the background this sets msDS-AllowedToActOnBehalfOfOtherIdentity property to an NT Security Descriptor for the Hyper-V server’s computer account.  If you wanted to live migration both directions (which typically you would) than you would need to call this a second time specifying the source/destination with the other direction.

Get-ADComputer -Filter {Name -Like "DestinationHVServer"}  | Set-ADComputer -PrincipalsAllowedToDelegateToAccount (Get-ADComputer -Filter {Name -Like "SourceHVServer"})

Advanced Configuration

The function below does a much more complete job of configuration the PrincipalsAllowedToDelegateToAccount.  It adds the appropriate entries for both migration directions as well as it read’s in existing entries preserving previously configured options.

function Add-Hyper-V-LiveMigrationHosts
{
    Param
    (
        [String[]]
        $HyperVHosts
    )
    $HvAdObj = @()
    foreach ($HvHost in $HyperVHosts)
    {
        $HvAdObj+= Get-ADComputer -Filter {Name -Like $HvHost} `
            -Properties msDS-AllowedToActOnBehalfOfOtherIdentity
    }

    for ($destinationCtr = 0; $destinationCtr -lt $HvAdObj.Count; $destinationCtr++)
    {
        for ($sourceCtr = 0; $sourceCtr -lt $HvAdObj.Count; $sourceCtr++)
        {
            if ($sourceCtr -ne $destinationCtr)
            {
                $deligationPrinciples = @()
                foreach ($AllowedAccount in `
                    $HvAdObj[$destinationCtr]."msDS-AllowedToActOnBehalfOfOtherIdentity".Access)
                {
                    $samAccountName = $AllowedAccount.IdentityReference.Value
                    $samAccountName = $samAccountName.Remove(0, ($samAccountName.IndexOf("\")+1))

                    $deligationPrinciples+=Get-ADComputer -Filter `
                        {SamAccountName -Like $samAccountName}
                 }

                $deligationPrinciples += $HvAdObj[$sourceCtr]
                $HvAdObj[$destinationCtr] | `
                    Set-ADComputer -PrincipalsAllowedToDelegateToAccount $deligationPrinciples   
            }
        }
    }
}

-taylorb

Author: "Taylor Brown [Microsoft Hyper-V]"
Comments Send by mail Print  Save  Delicious 
Next page
» You can also retrieve older items : Read
» © All content and copyrights belong to their respective authors.«
» © FeedShow - Online RSS Feeds Reader