Archive
Removing Virtual Networks : Script
You see this error message because the switch protocol is already enabled on that NIC. It’s enabled either because there is already a virtual network using that adapter or because something or someone enabled it incorrectly. If you already have a virtual network using that NIC, you can’t use that NIC on two virtual networks.
If you ever need to completely remove all virtual networks from your system, you could use one of the options below (I recommend extreme caution ):
Delete all your virtual networks.
I wouldn’t recommend running it remotely because it will tear down your network stack but it should restore it once completed.
/*
Copyright (c) Microsoft Corporation
Module Name:
nvspscrub.js
*/
//
// VirtualSwitchManagementService object. Logical wrapper class for Switch Management Service
//
function
VirtualSwitchManagementService(
Server,
User,
Password
)
{
//
// Define instance fields.
//
this.m_VirtualizationNamespace = null;
this.m_VirtualSwitchManagementService = null;
//
// Instance methods
//
VirtualSwitchManagementService.prototype.DeleteSwitch =
function(
VirtualSwitch
)
/*++
Description:
Deletes a virtual switch
Arguments:
VirtualSwitch – Msvm_VirtualSwitch object to delete
Return Value:
SWbemMethod.OutParameters object.
–*/
{
var methodName = "DeleteSwitch";
var inParams = this.m_VirtualSwitchManagementService.Methods_(methodName).inParameters.SpawnInstance_();
inParams.VirtualSwitch = VirtualSwitch.Path_.Path;
return this.m_VirtualSwitchManagementService.ExecMethod_(methodName, inParams);
}
VirtualSwitchManagementService.prototype.DeleteInternalEthernetPort =
function(
InternalEthernetPort
)
/*++
Description:
Deletes an internal ethernet port
Arguments:
InternalEthernetPort – Msvm_InternalEthernetPort to delete
Return Value:
SWbemMethod.OutParameters object.
–*/
{
var methodName = "DeleteInternalEthernetPort";
var inParams = this.m_VirtualSwitchManagementService.Methods_(methodName).inParameters.SpawnInstance_();
inParams.InternalEthernetPort = InternalEthernetPort.Path_.Path;
return this.m_VirtualSwitchManagementService.ExecMethod_(methodName, inParams);
}
VirtualSwitchManagementService.prototype.UnbindExternalEthernetPort =
function(
ExternalEthernetPort
)
/*++
Description:
Unbinds an external ethernet port from the virtual network subsystem. Usually this method
won’t be called directly
Arguments:
SwitchPort – Msvm_ExternalEthernetPort to unbind.
Return Value:
SWbemMethod.OutParameters object.
–*/
{
var methodName = "UnbindExternalEthernetPort";
var inParams = this.m_VirtualSwitchManagementService.Methods_(methodName).inParameters.SpawnInstance_();
inParams.ExternalEthernetPort = ExternalEthernetPort.Path_.Path;
return this.m_VirtualSwitchManagementService.ExecMethod_(methodName, inParams);
}
//
// Utility functions
//
VirtualSwitchManagementService.prototype.WaitForNetworkJob =
function(
OutParams
)
/*++
Description:
WMI calls will exit with some type of return result. Some will require
a little more processing before they are complete. This handles those
states after a wmi call.
Arguments:
OutParams – the parameters returned by the wmi call.
Return Value:
Status code
–*/
{
if (OutParams.ReturnValue == 4096)
{
var jobStateStarting = 3;
var jobStateRunning = 4;
var jobStateCompleted = 7;
var networkJob;
do
{
WScript.Sleep(1000);
networkJob = this.m_VirtualizationNamespace.Get(OutParams.Job);
} while ((networkJob.JobState == jobStateStarting) ||
(networkJob.JobState == jobStateRunning));
if (networkJob.JobState != jobStateCompleted)
{
throw(new Error(networkJob.ErrorCode,
networkJob.Description + " failed: " + networkJob.ErrorDescription));
}
return networkJob.ErrorCode;
}
return OutParams.ReturnValue;
}
VirtualSwitchManagementService.prototype.GetSingleObject =
function(
SWbemObjectSet
)
/*++
Description:
Takes a SWbemObjectSet which is expected to have one object and returns the object
Arguments:
SWbemObjectSet – The set.
Return Value:
The lone member of the set. Exception thrown if Count does not equal 1.
–*/
{
if (SWbemObjectSet.Count != 1)
{
throw(new Error(5, "SWbemObjectSet was expected to have one item but actually had " + SWbemObjectSet.Count));
}
return SWbemObjectSet.ItemIndex(0);
}
//
// Aggregate functions
//
VirtualSwitchManagementService.prototype.DeleteSwitchAndWait =
function(
VirtualSwitch
)
/*++
Description:
Deletes a switch
Arguments:
VirtualSwitch – Msvm_VirtualSwitch to delete
Return Value:
None.
–*/
{
var outParams = this.DeleteSwitch(VirtualSwitch);
var wmiRetValue = this.WaitForNetworkJob(outParams);
if (wmiRetValue != 0)
{
throw(new Error(wmiRetValue, "DeleteSwitch failed"));
}
}
VirtualSwitchManagementService.prototype.DeleteInternalEthernetPortAndWait =
function(
InternalEthernetPort
)
/*++
Description:
Deletes an internal ethernet port
Arguments:
InternalEthernetPort – Msvm_InternalEthernetPort to delete
Return Value:
SWbemMethod.OutParameters object.
–*/
{
var outParams = this.DeleteInternalEthernetPort(InternalEthernetPort);
var wmiRetValue = this.WaitForNetworkJob(outParams);
if (wmiRetValue != 0)
{
throw(new Error(wmiRetValue, "DeleteInternalEthernetPortAndWait failed"));
}
}
VirtualSwitchManagementService.prototype.UnbindExternalEthernetPortAndWait =
function(
ExternalEthernetPort
)
/*++
Description:
unbinds an internal ethernet port
Arguments:
ExternalEthernetPort – Msvm_ExternalEthernetPort to unbind
Return Value:
SWbemMethod.OutParameters object.
–*/
{
var outParams = this.UnbindExternalEthernetPort(ExternalEthernetPort);
var wmiRetValue = this.WaitForNetworkJob(outParams);
if (wmiRetValue != 0)
{
throw(new Error(wmiRetValue, "UnbindExternalEthernetPortAndWait failed"));
}
}
//
// Constructor code
//
if (Server == null)
{
Server = WScript.CreateObject("WScript.Network").ComputerName;
}
//
// Set Namespace fields
//
try
{
var locator = new ActiveXObject("WbemScripting.SWbemLocator");
this.m_VirtualizationNamespace = locator.ConnectServer(Server, "root\virtualization", User, Password);
}
catch (e)
{
this.m_VirtualizationNamespace = null;
throw(new Error("Unable to get an instance of Virtualization namespace: " + e.description));
}
//
// Set Msvm_VirtualSwitchManagementService field
//
try
{
var physicalComputerSystem =
this.m_VirtualizationNamespace.Get(
"Msvm_ComputerSystem.CreationClassName=’Msvm_ComputerSystem’,Name=’" + Server + "’");
this.m_VirtualSwitchManagementService = this.GetSingleObject(
physicalComputerSystem.Associators_(
"Msvm_HostedService",
"Msvm_VirtualSwitchManagementService",
"Dependent"));
}
catch (e)
{
this.m_VirtualSwitchManagementService = null;
throw(new Error("Unable to get an instance of Msvm_VirtualSwitchManagementService: " + e.description));
}
}
//
// main
//
var wshShell = WScript.CreateObject("WScript.Shell");
var g_NvspWmi = null;
Main();
function Main()
{
WScript.Echo("Looking for nvspwmi…");
g_NvspWmi = new VirtualSwitchManagementService();
WScript.Echo("");
WScript.Echo("Looking for internal (host) virtual nics…");
var list = g_NvspWmi.m_VirtualizationNamespace.ExecQuery("SELECT * FROM Msvm_InternalEthernetPort");
for (i = 0; i < list.Count; i++)
{
var next = list.ItemIndex(i);
WScript.echo(next.DeviceID);
g_NvspWmi.DeleteInternalEthernetPortAndWait(next);
}
WScript.Echo("");
WScript.Echo("Looking for switches…");
list = g_NvspWmi.m_VirtualizationNamespace.ExecQuery("SELECT * FROM Msvm_VirtualSwitch");
for (i = 0; i < list.Count; i++)
{
var next = list.ItemIndex(i);
WScript.echo(next.Name);
g_NvspWmi.DeleteSwitchAndWait(next);
}
WScript.Echo("");
WScript.Echo("Looking for external nics…");
list = g_NvspWmi.m_VirtualizationNamespace.ExecQuery("SELECT * FROM Msvm_ExternalEthernetPort WHERE IsBound=TRUE");
for (i = 0; i < list.Count; i++)
{
var next = list.ItemIndex(i);
WScript.echo(next.DeviceID);
g_NvspWmi.UnbindExternalEthernetPortAndWait(next);
}
WScript.Echo("");
WScript.Echo("Finished!");
}
Free Hyper-V training
Microsoft is offering free Hyper-V training!
Microsoft is offering some free Hyper-V training. You will need to enter a specific access code 9350-Y2W6-3676 and sign in with your Live ID. The course “Collection 6319 – Configuring Hyper-V in Windows Server 2008” includes the following modules:
1. An overview of the Hyper-V technology
2. Creating a virtual environment
3. Deploying systems in a virtual environment
4. Configuring high availability in a virtual environment
5. Administering a virtual environment with SCVMMTo sign up go to https://www.microsoftelearning.com/eLearning/enterCode.aspx
So, what are you waiting for?
Hyper-V in WS08 R2 Release Candidate : Live Migration Processor Compability
You’ll want to read Isaac’s blog post about the RC milestone of Windows Server 2008 R2. His post focuses on 64 LP support and processor compatibility mode for live migration. Read the post here.
Here’s an excerpt:
64LP Support
We have seen processors grow from 1, 2, 4, and now 6 cores on a single processor, soon to hit 8. Within the Windows Server 2008 R2 lifecycle, 64 logical processor servers will become commonplace (8 processors x 8 cores). Virtualization is the natural fit for these next-gen servers, allowing them to consolidate a greater number of virtual machines on a single host. Hyper-V is in line with these hardware trends all with an eye towards bringing you greater VM density. The dev team has done a fantastic job in building and testing a platform that can scale.
Let’s take a quick look at the history of logical processor support for Hyper-V:
- Server 2008 Hyper-V 16 LP Support
- Server 2008 Hyper-V +update (KB95670) 24 LP Support
- Server 2008 R2 Hyper-V Original POR 32 LP Support
- Server 2008 R2 Hyper-V RC/RTM 64 LP Support!
Processor Compatibility Mode for Live Migration
Live Migration is the killer-feature in Windows Server 2008 R2! Previous to the RC build of Windows Server 2008 R2, identical CPUs were needed across every node in the cluster in order to perform a live migration. As we came closer to the RC milestone we got feedback from customers and partners asking, "What if I deploy additional nodes that contain newer processors with features not contained in the original nodes?" Well, we’ve solved that problem due to tremendous effort by the Hyper-V development team.
Processor compatibility mode is very straightforward. It enables live migration across different CPU versions within the same processor family (i.e. Intel-to-Intel and AMD-to-AMD). However, it does NOT enable cross platform from Intel to AMD or vice versa. It works by abstracting the VM down to the lowest common denominator, in terms of instruction sets, which enables live migrations across a broader range of Hyper-V host hardware.
There are a few things to note: Processor compatibility mode is disabled by default but you can configure it on a per-VM basis. There are no specific hardware requirements other than the CPUs must support hardware assisted virtualization (i.e. Intel’s IVT and AMD’s AMD-V).
Alessandro
What is new in SCVMM 2008 R2 Release Candidate
Hi Guys
In addition to all the new capabilities R2 Beta introduced here’s what is new in SCVMM 2008 R2 Release Candidate:
Storage Migration:
Enables migration of storage for a running VM. This is especially relevant as customers upgrade to Windows 2008 R2 as it allows them to easily migrate away from their existing one VM per LUN deployments and consolidate their VMs into a single CSV. For Hyper-V, this feature enables migration of a running VM?s storage both within the same host and across hosts with minimum downtime. For VMWare, this feature enables storage vMotion.Rapid VM Provisioning:
Enables rapid creation of VMs without the need to copy VHDs over the network. Customers can now use storage technologies such as snap cloning to clone VHDs and then use the rapid provisioning feature to create VMs while continuing to take advantage of the VMM features to do OS customization and IC installation.Host compatibility checks:
Enables checks for CPU features and enlightenment parity to ensure compatibility between a VM and a host prior to migration. A related feature to make a VM compatible with a host by limiting the use of certain CPU features is also enabled.Queuing of Live migrations:
Enables users to do multiple live migrations within a cluster. VMM now detects the condition where live migrations fail due to collisions with in-progress live migrations and automatically performs queuing and retries in the background.Support for 3rd party CFS:
Enables support for clustered file systems from ISVs that implement functionally similar to CSV (Clustered shared volumes). This feature allows for backwards support for CSV scenarios on Windows 2008.Support for Custom Disk resource:
Enables support for Veritas volume manager by recognizing Veritas volume manager disks as a cluster disk resources.
To get assistance with the RC please participate in our public forums: http://social.technet.microsoft.com/Forums/en-US/category/virtualmachinemanager
Managing Hyper-V Server 2008 R2
Hyper-V Server 2008 R2 Live Migration and High Availability can be managed in a few different ways:
- Failover Cluster Manager/Hyper-V Manager from a Windows Server 2008 R2 Server OR,
- System Center Virtual Machine Manager 2008 R2 OR,
.using the FREELY (there’s that word again) available Failover Cluster Manager/Hyper-V Manager for Windows 7. So, as you can see, there are a few different options depending on your needs and option three give you Live Migration and High Availability at zero cost.
BTW: If you decide to go with option #2 System Center Virtual Machine Manager 2008 R2, you certainly can do a lot more such as:
- Heterogeneous Virtualization Management
- Rich PowerShell Support for Datacenter Automation
- Maintenance mode
- Virtual Machine Library Support
- Templates, Clones, Sysprep Integration
- Performance Resource Optimization (PRO)
.and a lot, lot more. But, I digress.
$$$ Comparison
Let’s take a look at a few cluster configurations and compare costs for Live Migration and High Availability functionality.
|
Hyper-V Server 2008 R2 |
VMware vSphere |
|
|
3 Node Cluster; 2 Socket Servers |
Free |
$13,470 |
|
3 Node Cluster; 4 Socket Servers |
Free |
$26,940 |
|
5 Node Cluster; 2 Socket Servers |
Free |
$22,450 |
|
5 Node Cluster; 4 Socket Servers |
Free |
$44,900 |
You may be wondering, "Did he choose the most expensive VMware configuration?" On the contrary, I chose the least expensive configuration ($2245 per processor) that offers both Live Migration and High Availability.
You may be wondering, "Why isn’t System Center management represented here?"
In this example, I simply wanted to compare the lowest cost for Live Migration and High Availability functionality from Microsoft and VMware with some real world configurations that a small/medium business may use. I will post a follow-up blog that adds management for small/medium businesses. As for enterprise customers, they typically have larger server farms with more sophisticated management requirements. That’s another blog for another time.
You may also be wondering, "Why isn’t the cost of guest operating systems included here?"
Simple, neither Microsoft Hyper-V Server 2008 R2 nor VMware include any guest operating system licenses so if you need to run 4 copies of Windows Server, you need to purchase the appropriate license. That cost is the same whether you’re running Hyper-V Server 2008 R2 or VMware so I didn’t bother to include it.
While VMware claims to be more affordable the facts are clear and the value of Microsoft Hyper-V Server 2008 R2 is undeniable. Microsoft offers exceptional value especially for small and mid-market customers who have told us for years how they would like Live Migration/High Availability functionality and simply can’t afford it.
Those days are over.
At this point you may be thinking we’re crazy to provide virtualization live migration and high availability at no cost. Well, I wish we could say we were first, but the folks at Xen have been providing free Live Migration and HA for a few months. In fact, the only one still charging for Live Migration and High Availability ($2245+ per socket) is VMware.
Now that’s crazy.
Published on http://blogs.technet.com/virtualworld/default.aspx by Jeff Woolsey, Principal Group Program Manager, Windows Server, Hyper-V
HP publishes 2 whitepapers on NIC teaming support in Hyper-V
HP has published 2 whitepapers that talk about NIC teaming support in Hyper-V running on HP hardware.
1. Using HP ProLiant Network Teaming Software with Microsoft Windows Server 2008 Hyper-V – How to
2. HP ProLiant Network Adapter Teaming
Rapid Provisioning in VMM 2008 R2 using the UseLocalVirtualHardDisks and SkipInstallVirtualizationGuestServices flags
Here is a sample script where a new virtual machine is created by utilizing the local VHD d:file.vhd without copying any VHDs over the network.
<<
#specify the file location
$VHDName = "d:file.vhd"
#specify other variables for new-vm
$vmname = "vm1"
$hostname = "host.contoso.com"
$vmhost = get-vmhost $hostname
#create jobgroup ID for new-vm from template
$VMGuid = [System.Guid]::NewGuid().ToString()
#specify the local location for the VHD
#VMM expects that $VHDName already exists on the host computer when the new-vm cmdlet is called.
Move-VirtualHardDisk -Bus 0 -LUN 0 -IDE -Path $VHDName -JobGroup $VMGuid
#get the template name
$template = Get-Template | where {$_.Name -eq "template_2"}
#Get the current username to be passed as the VM owner
$callerUsername = whoami
#create the new-vm from template and specify the Rapid Provisioning flag (-uselocalvirtualharddisks)
New-VM -Template $template -Name $vmname -Description "" -Owner $callerUsername -VMHost $vmhost -UseLocalVirtualHardDisks -Path $vmhost.VMPaths[0] -RunAsynchronously -JobGroup $VMGuid | Out-Null
>>
Thanks to Michael Michael from http://blogs.technet.com/m2/
What’s new in the Windows 2008 R2 RC
Windows Server 2008 R2 isn’t just about performance, and it certainly isn’t a fine-tuning of the Windows 2008, as its name implies.
The new Windows 2008 Server R2 increases the capabilities and features of the Windows Server line-up.
The RC version includes a number of new features and changes since the Beta.
Hyper-V improvements
Hyper-V 2.0 will include a long-awaited Live Migration feature. But there are some changes coming in:
– VM Chimney provides TCP offload support to virtual machines. That is, it allows you to map a VM to a physical network interface card (NIC) on the host computer, and bypass the virtual interface, improving performance. This feature is actually disabled by default because certain non-standard workloads actually experience a performance decrease. But in certain scenarios, like SQL backup and restore and Live Migration, VM Chimney will provide dramatic improvements.
– Virtual Machine Queue (VMQ). Like VM Chimney, it’s disabled by default. The reason this time is that only one vendor, Intel, currently makes VMQ-enabled hardware, and Microsoft didn’t want a feature enabled that wasn’t doing anything. If you do get a VMQ-enabled NIC (Qualcomm has also announced they’re entering this market), you can enable it and see a performance bump.
Performance and scalability improvements
Windows Server 2008 R2 bumps up the number of logical processors supported by the OS from 64 to 256.
Windows Server 2008 R2 provides power consumption reductions compared with Server 2008 and, more dramatically, with Server 2003.
R2 also offers some improvements around the size of the working memory footprint. Using its internal engineering memory metric (i.e. not Task Manager), Windows Server 2003 Enterprise occupies about 250 MB of RAM at idle. This compares to a bit over 150 MB for Windows Server 2008 and about 105 MB for R2. Server Core sees similar improvements: It’s down from about 130 MB in Server 2008 to under 100 MB for R2.
Finally, WAN file copies see significant improvements, though you will need compatible systems (i.e. Windows Server 2008 R2 and/or Windows 7) on both ends of the transfers (hub and branch) to see them. Microsoft says that small and medium file uploads are up to 20 percent improved over Windows Server 2008/Vista, small and medium file downloads are improved up to 47 percent, and large file uploads are improved by up to 100 percent. Microsoft is also seeing up to 8 times improvements copying files across WANs with RoboCopy using its new multithreading capability.
Note : Windows Server 2008 R2 is a 64-bit only release. Microsoft projects that the next Windows Server release will occur in 2012.
Hyper-V and in-place upgrade to Windows Server 2008 R2 Release Candidate
Hyper-V and in-place upgrade to Windows Server 2008 R2 Release Candidate
A cautionary note for those of you performing an in-place upgrade of a machine running Windows Server 2008 with the Hyper-V role enabled, to Windows Server 2008 R2 Release Candidate.
During the installation, you will see the following compatibility report message stating that you should turn off the Hyper-V role:
This warning is incorrect, and you should not do this as the virtual machines will not be present, and virtual network configuration will be lost once the role is re-enabled.
You will see a similar message if you have virtual machines running at the time of upgrade, but it is a “hard block” (in other words, you cannot proceed further). In the case where you hit the hard block, running VMs should be cleanly shut down prior to upgrade. However, I re-iterate, you should not remove the role itself.
One other point to note is if you have online snapshots or virtual machines in a saved state. Saved states are not compatible between Hyper-V in Windows Server 2008 and Windows Server 2008 R2 RC build, so you should ensure you cleanly shut down VMs and delete online snapshots prior to upgrading to avoid the following message after the upgrade is complete:


