May, 2008

  • Windows Virtualization Team Blog

    Hyper-V Release Candidate 1 (RC1) Available on Windows Update!

    • 4 Comments

    The Release Candidate 1 (RC1) of Hyper-V is now available as a optional update on Windows Update.  Optional updates are not installed automatically by default.  To install the update open the Windows Update control panel and click “View available updates” under the “Install Updates” button.  Then check the Update for Windows Server 2008 (KB950049) and click install.

    If you don’t see the update listed there could be a few reasons:
    1)  You may find that you need to click the “Check for Updates” or “Check online for updates from Windows Update
    2)  Depending on how busy the Windows Update servers are it may take a few days to get pushed out to every server.
    3)  If you have the HP Network Configuration Utility installed you should refer to KB950792.

    For additional information about RC1 see the previous Hyper-V RC1 Release Available on Microsoft Download Center! post.

    Enjoy and Happy Virtualizing!
    - Taylor Brown
    - Hyper-V Test Team

    image

  • Windows Virtualization Team Blog

    Hyper-V WMI Using PowerShell Scripts – Part 5

    • 3 Comments

    I hope everyone had a great Memorial Day weekend – we had a four day weekend on the Hyper-V team which was excellent!  In this post I am going to show how to create a new virtual switch attached to an external network.  I’ll start with a complete script and then take it apart and explain what each part is doing.

    $VirtualSwitchService = get-wmiobject -class "Msvm_VirtualSwitchManagementService" -namespace "root\virtualization"
    $ReturnObject = $VirtualSwitchService.CreateSwitch([guid]::NewGuid().ToString(), "New External Switch", "1024","")

    #Create New Virtual Switch
    $CreatedSwitch = [WMI]$ReturnObject.CreatedVirtualSwitch

    #Create Internal Switch Port
    $ReturnObject = $VirtualSwitchService.CreateSwitchPort($CreatedSwitch, [guid]::NewGuid().ToString(), "InternalSwitchPort", "")
    $InternalSwitchPort = [WMI]$ReturnObject.CreatedSwitchPort

    #Create External Switch Port
    $ReturnObject = $VirtualSwitchService.CreateSwitchPort($CreatedSwitch, [guid]::NewGuid().ToString(), "ExternalSwitchPort", "")
    $ExternalSwitchPort = [WMI]$ReturnObject.CreatedSwitchPort

    $ExternalNic = get-wmiobject -namespace "root\virtualization" -Query "Select * From Msvm_ExternalEthernetPort WHERE IsBound=False"

    #Call SetupSwitch
    $Job = $VirtualSwitchService.SetupSwitch($ExternalSwitchPort, $InternalSwitchPort, $ExternalNic, [guid]::NewGuid().ToString(), "InternalEthernetPort")
    while (([WMI]$Job.Job.JobState -eq 2) -or ([WMI]$Job.Job.JobState -eq 3) -or ([WMI]$Job.Job.JobState -eq 4)) {Start-Sleep -m 100}
    [WMI]$Job.Job

    Before explaining the elements of the script, I think it’s important to explain a little about Hyper-V’s networking model.  Hyper-V’s networking model attempts to be a similar to a real network, there are virtual switches, virtual switch ports and network adapters.  When you create a new external virtual network you are actually creating a virtual switch, an internal and external switch port and a virtual network adapter on the host.

    So let's look at the script above section by section.

    Section 1 - Creating The Switch

    $VirtualSwitchService = get-wmiobject -class "Msvm_VirtualSwitchManagementService" -namespace "root\virtualization"
    $ReturnObject = $VirtualSwitchService.CreateSwitch([guid]::NewGuid().ToString(), "DemoExternal", "1024","")

    Create New Virtual Switch
    $CreatedSwitch = [WMI]$ReturnObject.CreatedVirtualSwitch

    This section get's the Msvm_VirtualSwtichManagmentService, this is similar to other management service classes like msvm_imagemanagmentsevice.  The second line creates the switch, the first parameter to this function is the switch name, typically a guid is a good unique name, the second parameter is the friendly name (what you will see in the UI), the third parameter is the number of learnable addresses in the switch, the last parameter the AzMan scope name (I'll talk more about those in a later post).  The third line retrieves the WMI object for the created switch.

     

    Section 2 - Creating Switch Ports

    #Create Internal Switch Port
    $ReturnObject = $VirtualSwitchService.CreateSwitchPort($CreatedSwitch, [guid]::NewGuid().ToString(), "InternalSwitchPort", "")
    $InternalSwitchPort = [WMI]$ReturnObject.CreatedSwitchPort

    #Create External Switch Port
    $ReturnObject = $VirtualSwitchService.CreateSwitchPort($CreatedSwitch, [guid]::NewGuid().ToString(), "ExternalSwitchPort", "")
    $ExternalSwitchPort = [WMI]$ReturnObject.CreatedSwitchPort

    This section creates the internal and external switch ports, think of these as the ports on a physical switch that you would attach to your PC or Modem.  In both cases we are calling the CreateSwitchPort method.  The first parameter is switch we created in the previous section, the second parameter is the switch port name again we using a guid, the third the friendly name this name does not have to be unique and can be anything you want, and the final parameter again is the AzMan scope.  We again retrieve the created switch port's as WMI objects.

     

    Section 3 - Retrieving External Ethernet Connection

    $ExternalNic = get-wmiobject -namespace "root\virtualization" -Query "Select * From Msvm_ExternalEthernetPort WHERE IsBound=False"

    This section retrieves the external Ethernet port think of this as the port on the modem or the actual network adapter on the physical machine.  This query should return only one adapter, in the query above I select all adapters on the machine that are not already bound to a switch (hence the IsBound=False) so if I had two network adapters that not bound this query would need to be more specific.  You'll need to figure out what your criteria will be try running "get-wmiobject -namespace "root\virtualization" -Query "Select * From Msvm_ExternalEthernetPort" this will return all of the information available to query against.

    Section 4 - Bringing It All Together

    $Job = $VirtualSwitchService.SetupSwitch($ExternalSwitchPort, $InternalSwitchPort, $ExternalNic, [guid]::NewGuid().ToString(), "InternalEthernetPort")

     
    while (([WMI]$Job.Job.JobState -eq 2) -or ([WMI]$Job.Job.JobState -eq 3) -or ([WMI]$Job.Job.JobState -eq 4)) {Start-Sleep -m 100}
    [WMI]$Job.Job

    This final section bring's it all together.  The SetupSwitch method takes the WMI objects for the switch, switch ports, external Ethernet port as well as a name and friendly name and binds all the switch port's together.  Up to this point if you looked in the Hyper-V Network Manger you would see your switch but it would be a private switch; after this it will be an external switch.  The last two lines just wait for the returned WMI object to complete and then prints out the object.

    That's it!  You now have an external network.

     

    - Taylor Brown
    - Hyper-V Test Team

    image

  • Windows Virtualization Team Blog

    Hyper-V Deployment Case Study – Sporton International

    • 1 Comments

    Managing 60 servers is no small feat when it comes to midsize company, Sporton International in Taiwan.  With limited IT resources, Sporton decided to turn to Systex Corporation (Microsoft Gold Certified Partner) to explore options to virtualize their physical servers in an effort to reduce operation cost while improving the agility and manageability of their server assets.  Here're the case study highlights:

    1) What was deployed?

    • 35 physical production servers were virtualized with Hyper-V Release Candidate into on three physical servers (that's 12:1 consolidation ratio).
    • 10 virtual machines were configured with Hyper-V clustering to support Sporton's business continuity and disaster recovery needs.
    • The Microsoft Assessment and Planning (MAP) Tool was used to collect the performance metrics of every server in the data center and to identify which servers were good candidates. The MAP tool saved a substantial amount (60%) of inventory and planning time – which otherwise would have to be done manually.

    2) Why deployed with Hyper-V?

    • Optimizing Hardware Assets to Cut Costs: Saved on 70% of hardware costs & increased server utilization from 10-15% to about 70%
    • Streamlining Provisioning to Boost Responsive IT Service: Cut the time it takes for our IT staff to provision a server by up to 70 percent, which is critical to the productivity of the development and IT departments
    • Improving Availability for Better Business Continuity: Provided better continuity of IT service to internal users through quick migration and clustering technology from Microsoft
    • Hyper-V offers better and more familiar user interface as well as lower cost of ownership than VMware

    3) In the customer’s own words....

    • "Hyper-V in Release Candidate 0 was so reliable that we deployed VMs into the production environment serving all Internet guests and customers, and our subsidiaries in Taiwan, China, and Korea" - Kathy Lin, IT Manager of Sporton International.
    • "Hyper-V is the best virtualization solution running on Windows Server 2008, with enhanced performance and stability for Sporton at a fraction of the cost of VMware’s hypervisor-based offering." - David Feng, Technical Services Director of Systex Corp.

    4) Where to find the tools mentioned in this case study and other key virtualization resources?

    If you want to learn more please CLICK HERE for the entire case study.

    Cheers,

    Baldwin Ng

    Sr. Product Manager, Virtualization Solution Accelerators + Microsoft Assessment and Planning Tool

  • Windows Virtualization Team Blog

    Hyper-V WMI Using PowerShell - Part 4 and Negative 1

    • 5 Comments

    I hope everyone is enjoying Hyper-V RC1 (yep I just linked to my own post -shamless maybe) but, as promissed here's some more WMI goodness.   

    Title got your attention?  Well this is a two part post…  First I will show how to use the Shutdown IC to initiate a shutdown of a guest using PowerShell (that's part 4)  Ok so why Negative 1?  Well what did we do before PowerShell (yeah yeah vbscript but go with me) one option was C# so Part Negative 1 is a C# Example…

    Here’s the PowerShell to shutdown a VM named “Vista”… Just like previous examples, we get the Msvm_ComputerSystem… then we use the Associators of query to get the Msvm_ShutdownComponent associated with that VM.  Then we just call InitiateShutdown, the first parameter is wether to force a shutdown (like running shutdown /f inside the virtual machine) and the second is the reason for the shutdown.  It really is that simple.

    $Vm = Get-WmiObject -Namespace root\virtualization  -Query "Select * From Msvm_ComputerSystem Where ElementName='Vista'"


    $ShutdownIC = Get-WmiObject -Namespace root\virtualization  -Query "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_ShutdownComponent"


    $ShutdownIC.InitiateShutdown("TRUE", "Need to shutdown")

    And here’s the same code in C#…

    using System;
    using System.Collections;
    using System.Text;
    using System.Management;
    
    
    namespace ShutdownViaIC
    {
        class Program
        {
            static void Main(string[] args)
            {
                //Connect to the Remote Machines Management Scope
                ConnectionOptions options =  new ConnectionOptions();
                ManagementScope scope = new ManagementScope(@"\\localhost\root\virtualization"); scope.Connect();
    
                //Get the msvm_computersystem for the given VM (Vista)         
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope,
                    new ObjectQuery("SELECT * FROM Msvm_ComputerSystem WHERE ElementName = 'Vista'"));
    
                //Select the first object in the Searcher collection
                IEnumerator enumr = searcher.Get().GetEnumerator();
                enumr.MoveNext();
                ManagementObject msvm_computersystem = (ManagementObject)(enumr.Current);
    
                //Use the association to get the msvm_shutdowncomponent for the msvm_computersystem
                ManagementObjectCollection collection = msvm_computersystem.GetRelated("Msvm_ShutdownComponent");
                ManagementObjectCollection.ManagementObjectEnumerator enumerator = collection.GetEnumerator();
                enumerator.MoveNext();
                ManagementObject msvm_shutdowncomponent = (ManagementObject)enumerator.Current;
    
                //Get the InitiateShudown Parameters
                ManagementBaseObject inParams = msvm_shutdowncomponent.GetMethodParameters("InitiateShutdown");
                inParams["Force"] = true;
                inParams["Reason"] = "Need to Shutdown";
    
                //Invoke the Method
                ManagementBaseObject outParams = msvm_shutdowncomponent.InvokeMethod("InitiateShutdown", inParams, null);
                uint returnValue = (uint)outParams["ReturnValue"];
    
                //Zero indicates success
                if (returnValue != 0)
                    Console.WriteLine("SHUTDOWN Failed");            
            }
        }
    }

    PowerShell like most scripting languages can do simple tasks well simply, but your power and control is limited… This is still the case with PowerShell the code to initiate this shutdown is dead simple in PowerShell and all of three lines, you have more ‘using’ lines than that in the C# code…  However when it comes to writing more complex solutions like a Windows service that monitors Hyper-V and implements some custom business logic C# is a great choice… (it’s what the Hyper-V UI is written in).

    --Taylor Brown
    --Hyper-V test team

  • Windows Virtualization Team Blog

    Industry Buzz about Hyper-V

    • 2 Comments

    Greetings!  Robb Mapp here again, I’m the analyst relations manager in Server & Tools focused on Integrated Virtualization and System Center management tools. Post-MMS, and leading up to general availability this summer, we’re hearing a lot of great buzz in the industry about Hyper-V + VMM 2008 and I’d like to point out some recent analyst predictions for Microsoft’s impact on the server virtualization market. One that caught my eye is a certain IT analyst firm’s report that highlights data around visitors to their website who conduct search inquiries on server virtualization. What it finds is that their clients are requesting Microsoft’s technologies as much as VMware (and in some months, more than). 

    Another analyst point of view regarding the impending Microsoft Hyper-V vs. VMware ESX standoff comes from Burton Group’s Chris Wolf who blogged earlier this month about the importance of strong management to the success of a virtualization environment: “Management of physical resources, applications and operating systems is equally as critical, and represents a clear distinction between the Microsoft management solution and that of VMware.” Check out Mark Bowker for more virtualization commentary as well as thoughts regarding Microsoft surpassing VMware in virtualization production workloads.

    It’s nice to see evidence of increased Hyper-V awareness and industry acknowledgement of competitive differentiation as we bring Hyper-V to market. If you’re keeping track of where we’re at with Hyper-V, check out our Hyper-V RC1 announcement made earlier today.

    -Robb 

  • Windows Virtualization Team Blog

    Hyper-V RC1 Release Available on Microsoft Download Center!

    • 42 Comments

    Apologies for a lack of a new post on the WMI scripts, look for a new double part post Wednesday morning.  I was a bit busy with Hyper-V RC1!

    As of 2AM PST I am very happy to be the first (I think) to announce Hyper-V RC1 is now available for public download via the Microsoft Download Center.  I want to personally thank the great team of Testers, Developers and Program Mangers that make up the Hyper-V Team, there are several improvements in RC1 that they worked very hard on.


    Windows Server 2008 x64 Hyper-V RC1 Update - KB950049
    This is the Hyper-V RC1 package for Windows Server 2008 x64. This package must be installed on Hyper-V server’s (physical machines).  It includes the Hyper-V Server components for Full and Core installs, the Hyper-V Integration Components for Server 2008 x64 (see note below for RC1 improvements over RC0) and the Hyper-V Management Components for Full Windows installs.
    Note This package is permanent.  Once installed, it cannot be uninstalled.  So you can’t got back to RC0 or Beta after installing RC1.


    Windows Server 2008 x86 Hyper-V RC1 Update – KB950049
    This is the Hyper-V RC1 package for Windows Server 2008 x86. This package includes only the Hyper-V Management Components for Full Windows installs and the Hyper-V Integration Components for Server 2008 x86 (see note below for RC1 improvements over RC0)It does not contain the Hyper-V Server components, Hyper-V is x64 only!
    Note This package is permanent.  Once installed, it cannot be uninstalled.  So you can’t got back to RC0 or Beta after installing RC1.


    Hyper-V Management For Windows Vista SP1 -KB949587 
    I highly recommend John Howard's 5 part post on Hyper-V Remote Management.
    Windows Vista SP1 – x86 Update
    Windows Vista SP1 – x64 Update


    Hyper-V RC0 to RC1 Upgrade Considerations
    *Saved-state files are not supported between RC0 and RC1 releases of Hyper-V.  All virtual machine saved states should be discarded before upgrading to RC1, or prior to resuming virtual machines after upgrading to Hyper-V RC1. 

    *Online snapshots contain virtual machine save-states and thus online snapshots taken with Hyper-V RC0 are not supported after updating to Hyper-V to RC1.  Either apply any online snapshots and shut down the VM or discard the virtual machine save state associated with the snapshot before or after the update to Hyper-V RC1.

    *System Center Virtual Machine Manager 2008 Beta does not support Hyper-V RC1.

    *New Integration Components (ICs) must be installed for your supported guest operating systems.  Integration Components are specific to the build of Hyper-V.  RC1 Integration Components for all supported Windows Operating Systems are provided using the ‘Action’ -> ‘Insert Integration Services Setup Disk’ action.

    RC1 Integration Components for all supported Windows Operating Systems are now part of the IC Setup Disk.  This now includes Windows Server 2008!  Simply install the Hyper-V RC1 Integration Components for Windows Server 2008 the same way you do all other Windows ICs (‘Action’ -> ‘Insert Integration Services Setup Disk’). 
    Note You need to close the found new hardware wizard before setup will begin on all Windows Operating Systems.


    Improvements Over Hyper-V RC0
    In addition to bug fixes and stability improvements we also made some additional changes largely based on feedback from customers, I might have missed a few I’ll add to this list if so…
       *Integration Components For Windows Server 2008 guest’s included in Integration Services Setup Disk
       *New Graphics for Hyper-V Manager and Virtual Machine Connection – including a “Now” icon in the snapshot pane
       *IPv4 Address Migration - when creating a new Virtual Network bound to an adapter with a static IPv4 address the IPv4 settings are migrated to the new virtual adapter

    Enjoy and Happy Virtualizing!
    - Taylor Brown
    - Hyper-V Test Team

    image

  • Windows Virtualization Team Blog

    MSDN and TechNet Powered by Hyper-V

    • 44 Comments

    Hi—I am Rob Emanuel from the Microsoft.com Operations team.  For those of you who may not know what we do, our group designs, deploys, manages and sustains highly available, highly scalable Web and SQL systems for Microsoft for some of the largest corporate web sites in the world (www.microsoft.com, Microsoft Update, Download Center, MSDN and TechNet).  Along with our team’s TechCenter, we maintain a blog on how we adopt our own products and share some of our real world experiences.  

     

    For the last several months we have had the opportunity to focus on virtualizing both the MSDN and TechNet websites with Windows Server 2008 Hyper-V as a start to our overall virtualization adoption strategy. This was a group effort across our entire Operations Team including individuals from the Technical Architecture group I am part of, the System Engineers who run the sites, the data center hosting team which handles our infrastructure changes and the very supportive product group which is responsible for MSDN and TechNet.  Today we are very pleased to be able to share how Hyper-V was deployed for those two sites and our lessons learned through that process.  We have written an article on the TechCenter which goes through how we approached virtualizing MSDN and TechNet and hopefully conveys how successful we found Hyper-V to be as a web platform.

     

    The article covers the reasons and characteristics which made MSDN the first site we looked to move onto Hyper-V.   It provides an overview of how both Hyper-V Beta and Hyper-V RC0 were deployed as well as the general architecture used for the deployment.   Possibly the most surprising finding was that Hyper-V was far more stable than we had expected for a beta version deployment.  There was in fact no difference we found in stability or availability between Hyper-V and a physical deployment!  We were also not able to identify any bugs for the Hyper-V team during our deployment under either full production load or even stress load.

     

    An excerpt from the article:

     

    Implementation

    The rollout of Hyper-V in our production environment followed our standard approach to new technology adoption. Our architecture allows us to use global and local load balancing to quickly bring clusters or individual servers into and out of rotation. We heavily leverage this agility during our technology adoption efforts. This helps us safely bring new systems under production load in a controlled manner, while ensuring a continued positive customer experience.

    After analyzing the results of some standard performance tests (for example, memory, CPU, and I/O) our confidence in Hyper-V was such that we moved to site-specific testing in production. We monitored the site with normal production monitors while gathering detailed performance metrics specific to each physical server and virtual machine (VM). The production monitors include basic server health as well as end-to-end application tests. This ensured that the deployment was meeting or exceeding previous MSDN and TechNet site performance and availability targets.

    Hyper-V Beta Deployment

    Our production testing began in early February 2008, when we installed the Hyper-V role on two physical servers, with each hosting three VMs running MSDN. Production load on these six VMs progressed from a cautious 1 percent to 20 percent very quickly and smoothly. During the next six weeks, we tested various amounts of load and VM combinations to better understand the performance characteristics and scalability of the product and the site. MSDN was also deployed directly onto matching physical servers to compare VMs against physical performance, scale, and stability with the same load characteristics.

    In an effort to push the site and Hyper-V to their performance limits, we replayed production IIS logs by using the Web Capacity Analysis Tool (WCAT) to understand the upper range performance and scale characteristics.

    We tested and compared one, two, and finally three VMs per physical server. The data gathered is in line with those discussed in the "MSDN and TechNet Virtualization Results" section later in this article. The performance and stability of MSDN on the Hyper-V Beta release were so encouraging that, with RC0 nearing release, we began making preparations to move to the next phase of implementation.

    Update: The full article can be seen here.

     

    The success of Hyper-V as a web platform for both MSDN and TechNet for performance and stability has given us the confidence to accelerate our plans to implement Hyper-V for many of the other sites we run, such as the live traffic testing of www.microsoft.com on Hyper-V, which we have already started.    We are also actively working on our internal adoption of SCVMM 2008 as a major part of our overall virtualization strategy.  

     

    As we deploy more systems with Hyper-V and have information from our adoption of SCVMM 2008 we will share that on our TechCenter  in the form of additional articles or blog entries.

     

    Happy deployments-

    Rob

  • Windows Virtualization Team Blog

    Unattended Installation of Windows Server 2008 with Hyper-V RC0

    • 4 Comments

    I am taking a quick break from the WMI PowerShell scripts while I take a short Mothers Day vacation, more WMI scripts when I get back! Unattended Hyper-V installation has been one of the most read TechNet forum posts I wrote and it also seems that a lot of people where doing the installation wrong.  This sample was generated using Windows Automated Installation Kit (AIK), this is a tool that allows you to build unattened xml files for Windows 6.0 OS’s (Vista and Server).

    Make sure you update the path to the update cab file.  To extract the cab file download the RC0 update from the Microsoft Download Center then run expand -f:* Windows6.0-KB949219-x64.msu <folderToExtractTo>.

     

    <?xml version="1.0" encoding="utf-8"?>
    <unattend xmlns="urn:schemas-microsoft-com:unattend">
        <servicing>
            <package action="install" permanence="permanent">
                <assemblyIdentity name="Package_for_KB949219" version="6.0.1.2" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" />
    <source location="<PathToUpdateCab>\Windows6.0-KB949219-x64.cab" />
            </package>
            <package action="configure">
                <assemblyIdentity name="Microsoft-Windows-Foundation-Package" version="6.0.6001.18000" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="" />
                <selection name="Microsoft-Hyper-V" state="true" />
                <selection name="Microsoft-Hyper-V-Management-Clients" state="true" />
            </package>
        </servicing>
    </unattend>

     

    Have a great Mothers Day weekend!!!  And remember every mom needs a copy of Windows Server with Hyper-V RC0 pre-installed, seriously odds are pretty good flowers are a better Mothers Day gift. :-)

    -Taylor Brown
    -Hyper-V Test Lead

  • Windows Virtualization Team Blog

    Hyper-V WMI Using PowerShell Scripts – Part 3

    • 5 Comments

    In part 1 we went over basic scripts and tools for gathering some generic information about virtual machines and in part 2 we went over VHD creation and WMI job’s.  In part 3 I am going to cover getting more detailed information about a guest operating system by using the KVP Exchange integration component.  KVP stands for Key Value Pair this is a service that runs in the guest operating system and allows some limited information to be passed from the guest to the host or parent and vice-verse.  For now we are going to focus only on the intrinsic KVP’s these are provided by default on virtual machines that have the integration components installed.  The intrinsic KVP’s include: FullyQualifiedDomainName, OsName, OsVersion, CSDVersion, OsMajorVersion, OsMinorVersion, OsBuildNumber, OsPlatformID, ServicePackMajor, SuiteMask, ProductType, ProcessorArhitecture.

    I’ll start with the PowerShell script and results and then explain how to decipher each of the KVP’s values but first I want to thank Ed one of our top notch developers that provided me this script...

    In the gray box is the body of the script, it’s a bit different then what we have seen in the past primarily because is what looks like a function at the top.  This function looking thing is a PowerShell filter, what the filter does is take a bunch of XML known in WMI as an “embedded instance" and converts it into objects.  If you want to see the XML in it’s raw form remove the "|Import-CimXml” from the last line of the script and you’ll see how handy this little filter is.

    So what’s happening in this script?  I will ignore the filter for a moment so the first line is the the $Vm = Get-Wmi… So the first line should look pretty common now, we are getting a Msvm_ComputerSystem WMI object for a given virtual machine “Server 2008 – Test1".  The second line is new, we are running an Association query to get a Msvm_KvpExchangeCompoents WMI object for this VM, associations are an optimization in WMI you can think of them like a SQL join statement “Please give me all of the X that corresponds to Y”.  The third line is just taking the GuestIntrinsicExchangeItems property of the Msvm_KvpExchangeCompoents and piping or sending it (that’s the | character) to the Import-CimXml filter that’s written above.  Now for the filter, so all this filter is doing is using an XML xpath query to go over each “Instance/Property” node and adding it’s name and value to this CimObj object and then returning that object…

    WMIKVP.ps1 PowerShell Script

    filter Import-CimXml
    {
        $CimXml = [Xml]$_
        $CimObj = New-Object -TypeName System.Object
        foreach ($CimProperty in $CimXml.SelectNodes("/INSTANCE/PROPERTY"))
        {
            $CimObj | Add-Member -MemberType NoteProperty -Name $CimProperty.NAME -Value $CimProperty.VALUE
        }
        $CimObj
    }

    $Vm = Get-WmiObject -Namespace root\virtualization -Query "Select * From Msvm_ComputerSystem Where ElementName='Server 2008 - Test1'"
    $Kvp = Get-WmiObject -Namespace root\virtualization -Query "Associators of {$Vm} Where AssocClass=Msvm_SystemDevice ResultClass=Msvm_KvpExchangeComponent"


    $Kvp.GuestIntrinsicExchangeItems | Import-CimXml

     

    Output of the WMIKVP.ps1 Script

    PS C:\> . 'D:\BlogsDemo\powerShell\Demo\WMIKVP.ps1'

    Caption     :
    Data        : AUTOBVT-M02LJSS
    Description :
    ElementName :
    Name        : FullyQualifiedDomainName
    Source      : 2

    Caption     :
    Data        : Windows Server (R) 2008 Enterprise
    Description :
    ElementName :
    Name        : OSName
    Source      : 2

    Caption     :
    Data        : 6.0.6001
    Description :
    ElementName :
    Name        : OSVersion
    Source      : 2

    Caption     :
    Data        : Service Pack 1
    Description :
    ElementName :
    Name        : CSDVersion
    Source      : 2

    Caption     :
    Data        : 6
    Description :
    ElementName :
    Name        : OSMajorVersion
    Source      : 2

    Caption     :
    Data        : 0
    Description :
    ElementName :
    Name        : OSMinorVersion
    Source      : 2

    Caption     :
    Data        : 6001
    Description :
    ElementName :
    Name        : OSBuildNumber
    Source      : 2

    Caption     :
    Data        : 2
    Description :
    ElementName :
    Name        : OSPlatformId
    Source      : 2

    Caption     :
    Data        : 1
    Description :
    ElementName :
    Name        : ServicePackMajor
    Source      : 2

    Caption     :
    Data        : 0
    Description :
    ElementName :
    Name        : ServicePackMinor
    Source      : 2

    Caption     :
    Data        : 274
    Description :
    ElementName :
    Name        : SuiteMask
    Source      : 2

    Caption     :
    Data        : 3
    Description :
    ElementName :
    Name        : ProductType
    Source      : 2

    Caption     :
    Data        : 9
    Description :
    ElementName :
    Name        : ProcessorArchitecture
    Source      : 2

    Ok now how do you decipher all of these values like SuiteMask?   All of this data except the fully qualified domain name come from a Windows API GetVersionEx but what you really want to look at is the OSVERSIONINFOEX structure.  That documents each of these values, for example SuiteMask has a value of 274 above that's 0x112 and according to the documents that means this guest has: Remote Desktop support, Terminal Services is installed, and it's running an Enterprise SKU of Windows... 

    There's a lot more you can do with the KVP's such as pushing custom data into the guest from the parent partition/host or providing data from the guest so that the parent partition/host can query it.  I can provide samples for this in a future post but only if you want me to - so tell me, actually tell me what posts you want maybe networking or offline vhd servicing or maybe import/export?

    --Taylor Brown
    --Hyper-V test team

  • Windows Virtualization Team Blog

    Hyper-V WMI Using PowerShell Scripts – Part 2

    • 4 Comments

    In part 1 we went over some basic scripts and tools for gathering information about running virtual machines.  In part 2 I am going to cover two things, first basic VHD creation and second determining if Hyper-V WMI methods are succeeding or failing and what the error message is.

    PowerShellPlus

    Last time I showed the PowerShell 2.0CTP which includes the Graphical PowerShell interface… Those of you that plan to do a lot PowerShell development might want to check out PowerShellPlus (http://www.powershell.com/index.html).  It’s a $79 investment if you are using it for commercial use, but there is a 30 day trial – 1 day down and so far I think it’s worth $79…  As you can see from the screen capture below the editor offers auto-complete as well as a pretty good debugger.

    PowerShellPlus

    Creating a VHD Using PowerShell WMI

    Creating a VHD using the Hyper-V WMI is pretty easy… And once again PowerShell makes it even easier… 

    The first command retrieves a WMI object for Msvm_ImageManagmentService

    The second command executes the CreateDynamicVirtualHardDisk method to create a new dynamic VHD.  PowerShell is smart enough to know that 20GB = 20 * 1073741824... That’s so COOL!.

    PS D:\> $VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization"
    PS D:\> $VHDService.CreateDynamicVirtualHardDisk("D:\vhds\TestVhd1.vhd", 20GB)

    __GENUS          : 2
    __CLASS          : __PARAMETERS
    __SUPERCLASS     :
    __DYNASTY        : __PARAMETERS
    __RELPATH        :
    __PROPERTY_COUNT : 2
    __DERIVATION     : {}
    __SERVER         :
    __NAMESPACE      :
    __PATH           :
    Job              : \\TAYLORB-DP490\root\virtualization:Msvm_StorageJob.InstanceID='Microsoft:Msvm_{B5A1A0EC-6A86-4CB0-AF7A-B336CBA2DCFF}'
    ReturnValue      : 4096

    Finding Out If Your VHD Creation Succeeded Or Not…

    Let’s say you actually want to know if the VHD was created successfully or not (crazy I know…).  Well normally you would just check ReturnValue, but what the heck does 4096 mean?  4096 means that the method is executing asynchronously (in the background) and you need to check it’s Job object to see when it’s finished and if it was successful…

    As you can see from the ErrorDescription below my job actually failed since I didn’t delete the VHD between the first and second sample…  Most of the Hyper-V WMI uses these Job objects so this is a pretty handy bit of code to know…

    Again the first command just retrieves a WMI object for Msvm_ImageManagmentService.

    The second command is mostly the same except for three key parts, first you can see it stores the return object in $Job but the real magic is the [WMI] before the $VHDSer…  What’s happening is your telling PowerShell to make you a PowerShell WMI object for the Job path stored in the Job field. Look at the output from the sample above the Job field is a path to a WMI job object...

    The third command is just showing the output of the $Job… You could do $Job.ErrorDesciption if you wanted to just get the ErrorDescription..

    PS D:\> $VHDService = get-wmiobject -class "Msvm_ImageManagementService" -namespace "root\virtualization"
    PS D:\> $Job = [WMI]$VHDService.CreateDynamicVirtualHardDisk("D:\Users\Public\Documents\Hyper-V\Virtual hard disks\TestVhd1.vhd", 20GB).Job
    PS D:\> $Job

    __GENUS                 : 2
    __CLASS                 : Msvm_StorageJob
    __SUPERCLASS            : CIM_ConcreteJob
    __DYNASTY               : CIM_ManagedElement
    __RELPATH               : Msvm_StorageJob.InstanceID="Microsoft:Msvm_{22FE6994-4CD8-4D06-9F3D-906A23A4BB09}"
    __PROPERTY_COUNT        : 43
    __DERIVATION            : {CIM_ConcreteJob, CIM_Job, CIM_LogicalElement, CIM_ManagedSystemElement...}
    __SERVER                : TAYLORB-DP490
    __NAMESPACE             : root\virtualization
    __PATH                  : \\TAYLORB-DP490\root\virtualization:Msvm_StorageJob.InstanceID="Microsoft:Msvm_{22FE6994-4CD8-4D06-9F3D-906A23A4B
                              B09}"
    Caption                 : Storage Job
    Child                   :
    DeleteOnCompletion      : True
    Description             : Disk Creation Job.
    ElapsedTime             : 00000000000000.000000:000
    ElementName             : Storage Job
    ErrorCode               : 32768
    ErrorDescription        : The system failed to create 'D:\Users\Public\Documents\Hyper-V\Virtual hard disks\TestVhd1.vhd' with error 'The f
                              ile exists..' (0x80070050)
    ErrorSummaryDescription :
    HealthState             : 5
    InstallDate             : 00000000000000.000000+000
    InstanceID              : Microsoft:Msvm_{22FE6994-4CD8-4D06-9F3D-906A23A4BB09}
    JobCompletionStatusCode : 2147942480
    JobRunTimes             : 1
    JobState                : 10
    JobStatus               : Error
    LocalOrUtcTime          : 2
    Lun                     : 0
    Name                    : Msvm_StorageJob
    Notify                  :
    OperationalStatus       : {2}
    OtherRecoveryAction     :
    Owner                   :
    Parent                  :
    PathId                  : 0
    PercentComplete         : 0
    PortNumber              : 0
    Priority                : 0
    RecoveryAction          : 3
    RunDay                  :
    RunDayOfWeek            :
    RunMonth                :
    RunStartInterval        :
    ScheduledStartTime      :
    StartTime               :
    Status                  : Error
    StatusDescriptions      : {Error}
    TargetId                : 0
    TimeBeforeRemoval       : 00000000000000.000000:000
    TimeOfLastStateChange   : 00000000000000.000000+000
    TimeSubmitted           :
    Type                    : 1
    UntilTime               :

     

    Well I think that's going to have to do it for tonight… Stay tuned I have A LOT more to show. 

    If you prefer the examples in this format tell me, if you prefer the format from yesterday tell me, if you want a different format altogether tell me…

    -Good Night and Good Weekend
    -Taylor Brown

  • Windows Virtualization Team Blog

    Hyper-V WMI Using PowerShell Scripts – Part 1

    • 2 Comments

    Hello out there in blog land… This is Taylor Brown some of you may know me from the Virtualization Deployment Summit or from my posts on the TechNet Forums, for those who don’t know me I am a test lead on the Hyper-V team.  One of my team’s responsibilities is validating end-to-end integration of all the different parts of Hyper-V such as networking, storage, user-interface or installation.  We are also responsible for the relationship between you the customer and the rest of the Hyper-V test team. 

    Last week I did a demo of some Hyper-V WMI scripts in Powershell and enough people asked for them I figured I'll just post them for everyone…  So without further delay here's part 1.

    PowerShell 2.0 CTP – Graphical PowerShell Interface

    I highly recommend the PowerShell Graphical Interface that is included in the PowerShell 2.0 CTP. 

    You can read more about it and download the installation package at http://www.microsoft.com/technet/scriptcenter/topics/msh/download2.mspx.

    It offers a nice tabbed interface and color coding, its a CTP build so it’s far from bug-free but the benefits out way the pitfalls.  You have to uninstall the PowerShell 1.0 Windows update before you can install the CTP build.  I don't think I would install the CTP on your production servers, but the PowerShell scripts are generally compatible.

    The biggest downside to this interface for me is that it makes me want more features like auto-complete.

    PowerShell20CTP

     

    Mapping Worker Process ID's to Virtual Machines

    Each virtual machine has it's own worker process (vmwp.exe) instance when it's running.  Some people have asked how they can map worker process to a specific virtual machine so here's the answer... This is also a great example of the power that WMI and PowerShell have with Hyper-V. 

       1: $Vm = Get-WmiObject -Namespace root\virtualization -ComputerName "." `
       2: -Query "Select * From Msvm_ComputerSystem Where ElementName='Server 2008 - Test1'"
       3: $Vm.ProcessID
       4:  
       5: $Vm = Get-WmiObject -Namespace root\virtualization -ComputerName "." `
       6:    -Query "Select * From Msvm_ComputerSystem Where ProcessID=4044"
       7: $Vm.ElementName

    Lines 1 and 2 retrieves a WMI object for the virtual machine with the friendly name of 'Server 2008 - Test1'.  Then line 4 outputs the value in the ProcessID field to the console.

    Lines 5 and 6 retrieves the same WMI object as lines 1 and 2 did but retrieves it via the process id.  Then line 7 outputs the value in the ElementName (friendly name) of the virtual machine to the console.

    Other WMI Properties Of the Msvm_ComputerSystem

    msvm_computersystem

    One of the best parts about writing scripts in PowerShell over VBScript or JScript is that like a command or batch script you can run commands in the shell window and see the results right away...

    In this screen capture I just ran the command from line 1 and 2 above (hint remove the ` and carriage return from the end of line 1 to make the command a single line).

    Then I ran $Vm, which is the WMI object I retrieved.  This will output all of the properties that object contains.  Here's the list - stay tuned for later posts and I will talk about what these properties mean.

    PS C:\> $Vm = Get-WmiObject -Namespace root\virtualization -ComputerName "." -Query "Select * From Msvm_ComputerSystem Where ElementName='Server 2008 - Test1'"
    PS C:\> $Vm

    __GENUS                       : 2
    __CLASS                       : Msvm_ComputerSystem
    __SUPERCLASS                  : CIM_ComputerSystem
    __DYNASTY                     : CIM_ManagedElement
    __RELPATH                     : Msvm_ComputerSystem.CreationClassName="Msvm_ComputerSystem",Name="A1223A4B-887D-4F01-895E-FBFB636F76D8"
    __PROPERTY_COUNT              : 29
    __DERIVATION                  : {CIM_ComputerSystem, CIM_System, CIM_EnabledLogicalElement, CIM_LogicalElement...}
    __SERVER                      : TAYLORB-DP490
    __NAMESPACE                   : root\virtualization
    __PATH                        :
    \\localhost\root\virtualization:Msvm_ComputerSystem.CreationClassName="Msvm_ComputerSystem",Name="A1223A4B-887D-4F01-895E-FBFB636F76D8"

    AssignedNumaNodeList          : {0}
    Caption                       : Virtual Machine
    CreationClassName             : Msvm_ComputerSystem
    Dedicated                     :
    Description                   : Microsoft Virtual Machine
    ElementName                   : Server 2008 - Test1
    EnabledDefault                : 2
    EnabledState                  : 2
    HealthState                   : 5
    IdentifyingDescriptions       :
    InstallDate                   : 20080502051703.000000-000
    Name                          : A1223A4B-887D-4F01-895E-FBFB636F76D8
    NameFormat                    :
    OnTimeInMilliseconds          : 3783756
    OperationalStatus             : {2}
    OtherDedicatedDescriptions    :
    OtherEnabledState             :
    OtherIdentifyingInfo          :
    PowerManagementCapabilities   :
    PrimaryOwnerContact           :
    PrimaryOwnerName              :
    ProcessID                     : 4044
    RequestedState                : 12
    ResetCapability               : 1
    Roles                         :
    Status                        :
    StatusDescriptions            :
    TimeOfLastConfigurationChange : 20080502051707.000000-000
    TimeOfLastStateChange         : 20080502051707.000000-000

     

  • Windows Virtualization Team Blog

    Analyst perspectives on Microsoft's Integrated Virtualization strategy & System Center evolution, from MMS 2008

    • 0 Comments

    Greetings! My name is Robb Mapp and I’m the analyst relations manager in Server & Tools focused on System Center management tools and Integrated Virtualization. This week at MMS, we had nearly 60 industry analysts participate in a summit focused on strategies for systems management and virtualization. These summits are great for Microsoft, as it gives us an opportunity to truly engage in a productive dialogue with the infrastructure pundits. Two of the attending analysts – Neil Macehiter from Macehiter Ward-Dutton and Mark Bowker from Enterprise Strategy Group – were kind enough to sit down with me to discuss the role of an IT analyst and thoughts around our Integrated Virtualization strategy and our move to manage heterogeneous platforms. Enjoy the videos!

     

Page 1 of 1 (12 items)