Do you need a script to validate that a virtual switch is configured correctly? Using WMI you can get the virtual switches like this:
$VSwitches = Get-WMIObject -namespace "root\virtualization" -class "Msvm_VirtualSwitch"
You can get the adapters like this:
$Adapter = Get-WMIObject Win32_NetworkAdapter | Where {$_.NetconnectionID –eq “name”}
You can map adapters to ethernet ports like this:
$ExternalNIC = Get-WMIObject -namespace "root\virtualization" -query "SELECT * FROM Msvm_ExternalEthernetPort WHERE DeviceID='$($Adapter.GUID)'"
With these you can confirm that a switch with the same name exists. You can validate properties of the physical adapter (IP, etc…).
However, to tie these two pieces together, you can use the script below, which is a modification of Ben Armstrong’s script from http://blogs.msdn.com/b/virtual_pc_guy/archive/2009/02/24/script-determining-virtual-switch-type-under-hyper-v.aspx, using “Associators.”
$HyperVServer = "VMHost1"
$VSwitches = Get-WMIObject -namespace "root\virtualization" -class "Msvm_VirtualSwitch" -ComputerName $HyperVServer
foreach($VirtualSwitch in $VSwitches){
$query = "Associators of {$VirtualSwitch} where ResultClass=CIM_SwitchPort"
$switchPorts = gwmi -namespace "root\virtualization" -Query $query -computername $HyperVServer
# A VM only switch with no VMs connected will return null
if ($switchPorts -ne $null){
# Iterate over each switch port
foreach ($switchPort in @($switchPorts)){
# Get the Msvm_SwitchLANEndpoint associated with the switch port
$query = "Associators of {$switchPort} where ResultClass=Msvm_SwitchLANEndpoint"
$SwitchLANEndpoint = gwmi -namespace "root\virtualization" -Query $query -computername $HyperVServer
# If there is no active connection on the switch port the results will be null
if ($SwitchLANEndpoint -ne $null){
# Get the CIM_EthernetPort for the Msvm_SwitchLANEndpoint
$query = "Associators of {$SwitchLANEndpoint} where ResultClass=CIM_EthernetPort"
$EthernetPort = gwmi -namespace "root\virtualization" -Query $query -computername $HyperVServer
# Check to see if the associated Ethernet port is an external port
if ($EthernetPort.__CLASS -eq "Msvm_ExternalEthernetPort"){
$VirtualSwitch.ElementName
$EthernetPort.ElementName
}
Feel free to add to this (unsupported, as-is) script, it is the wiki way.
Colleague John Savill has put together a great 20 minute demo showing how (and why) to use Hyper-V Dynamic Memory and Remote FX (both available now in Windows Server 2008 R2 SP1 Beta). Click the image to play the video.
At around the 15 minute mark check out Disney World in 3d over RFX:
And about 2 minutes later, check out the Halo 2 over RFX action.
Here’s how to manage Hyper-V from a Windows 7 system.
1. Download and install the Remove Server Administration (RSAT) tools for Windows 7 from: http://www.microsoft.com/downloads/details.aspx?FamilyID=7D2F6AD7-656B-4313-A005-4E344E43997D&displaylang=en. Install either the 32-bit or 64-bit depending on what version of Windows 7 you’re using.
2. Open Control Panel and click Programs.
3. Click Turn Window features on or off.
4. Under Remote Server Administration Tools Role> Administration Tools check Hyper-V Tools.
Launch to tools by either typing Hyper-V Manager at the Start menu or go to Start>Administrative Tools>Hyper-V Manager.
One of the things customers asked of us when we met at TechEd 2010 is summarized as:
“It would be really useful if you would give me a table of <thing> and how it changes from version to version.”
The most frequent request was for <GPO>, but it really applies to a lot of <things> of interest to IT Pros.
So, how can we get you this info? It is quite difficult to do this on TN/MSDN, partly because everyone working on those properties is 110% focused on the next version of the product, and getting ready to give you the info you need for that.
Enter the TNWIKI. For example, this article “Exchange ActiveSync Client Comparison Table” has a table that compares the changes in the EAS client between different Exchange versions, and that, is salty goodness…
Now, imagine a topic like this that shows you how <your group policy object of interest> changed between versions of Windows Server? Better yet, go get stubby on it.
My colleague Kathy Davies has published a quick demo of DM in the SP1 Beta on YT:
Principal PM Vijay Tewari also showed DM, and Remote FX (both available in the SP1 Beta) at TechEd2010:
The product group has the definitive series of blog posts on Dynamic Memory, now available in Windows Server 2008 R2 SP1 Beta
Part 1: Dynamic Memory announcement. This blog announces the new Hyper-V Dynamic Memory in Hyper-V R2 SP1, including requirements. http://blogs.technet.com/virtualization/archive/2010/03/18/dynamic-memory-coming-to-hyper-v.aspx
Part 2: Capacity Planning from a Memory Standpoint. Details issues to consider for memory capacity planning and why. http://blogs.technet.com/virtualization/archive/2010/03/25/dynamic-memory-coming-to-hyper-v-part-2.aspx
Part 3: Page Sharing. Detailed discussion about the TLB, large memory pages, how page sharing works, SuperFetch and more. http://blogs.technet.com/virtualization/archive/2010/04/07/dynamic-memory-coming-to-hyper-v-part-3.aspx
Part 4: Page Sharing Follow-Up. Questions answered about Page Sharing and ASLR and other factors. http://blogs.technet.com/b/virtualization/archive/2010/04/21/dynamic-memory-coming-to-hyper-v-part-4.aspx
Part 5: Second Level Paging. Details why should avoid this in a virtualized environment, including Performance impacts. http://blogs.technet.com/b/virtualization/archive/2010/05/20/dynamic-memory-coming-to-hyper-v-part-5.aspx
Part 6: Hyper-V Dynamic Memory. Discusses DM, and each of the per virtual machine settings. http://blogs.technet.com/b/virtualization/archive/2010/07/12/dynamic-memory-coming-to-hyper-v-part-6.aspx
On the TechNet Wiki (Beta) we encourage IT Pros and Devs to start a wiki article, even though they may not have all the information required to complete it. Troubleshooting articles, in particular, as well as “link aggregations” can profit greatly from this approach.
Check out the How to Create a Stub Page article, and/or review the tag page for existing stubs waiting for help, and get stubby.
Here’s an example. I created the PowerShell Survival Guide in Feb 2010, and it looked like this (at 75% magnification):
Today, after scores of IT Pros and Devs from around the world contributing links to resources that they vouch for as valuable, it looks like this (in 15% magnification) - all in Green has been added by the community.
One of the metrics we keep an eye on for the TechNet Wiki (Beta) is number of article revisions. We view this number as one measure of increasing quality for the article. This article has been revised 100 times to date, and is also consistently in the top 5 or 10 articles when counting page views.
Come on in, the wiki’s fine…
One of the things a wiki should enable is great collaboration on troubleshooting. This kind of content greatly profits from many perspectives and contributors. The TechNet Wiki (Beta) also supports useful things not available in the TN/MSND library troubleshooting topics, like video, screenshots and scripts.
Want to contribute? Start your own troubleshooting topic,
…or help out by improving one of the existing topics:
Hyper-V: How to Detect if a Computer is a VM Using Script
DFSR Event 6002 (DFS Replication)
Troubleshooting SQL Server Express Installation
Troubleshoot DirectAccess in Windows Server 2008 R2
SCVMM How To: Remove failed jobs from SCVMM console
SCVMM V2V failed with Error (protocol error : too many authentication failures for root)
When you try to add Install Image to Windows Deployment Services you receive “The data area passed to a system call is too small” error message
Wiki: Troubleshooting Template
Some people find templates helpful when creating wiki articles. This one is intended to help those writing troubleshooting content, and is based on the Microsoft KB schema. This template is a work in progress, please add to it. Feel free to copy/paste the template below into your troubleshooting wiki...
Colleague Jim Holtzman is doing a very interesting (and helpful) thing over on the TechNet Wiki. Typically, when you look on TechNet or MSND for something like router (or any hardware really) setup instructions, you find an article that aims to serve the widest possible audience, and therefore does not go into depth on any one particular model or brand. Partly this is because to go into one hw setup and not another would be seen as “playing favorites” and you can’t document them all, right?
Well, on the wiki WE can. For example, Jim has started the ball rolling with 8 or so currently popular Windows Small Business Server 2008: Router Setups.
What’s that you say? Your router is not in the article? Go ahead and add it, it is the wiki way!
Imagine, one place where all the hw setup info for all the router OEMs can be found, and it has an RSS feed so you can get notified (if you subscribe) when it is updated.
Salty goodness. Well done Jim!
Hrmm, that gives me an idea about BIOS settings in Hyper-V….