Move from Hyper-V WMI v1 to WMI v2

Windows Management Instrumentation (WMI) is the management interface underlying Hyper-V Manager and Hyper-V's PowerShell cmdlets. While most people use our PowerShell cmdlets or Hyper-V manager, sometimes developers needed WMI directly.

There have been two Hyper-V WMI namespaces (or versions of the Hyper-V WMI API).

  • The WMI v1 namespace (root\virtualization) which was introduced in Windows Server 2008 and last available in Windows Server 2012
  • The WMI v2 namespace (root\virtualization\v2) which was introduced in Windows Server 2012

This document contains references to resources for converting code that talks to our old WMI namespace to the new one. Initially, this article will serve as a repository for API information and sample code / scripts that can be used to help port any programs or scripts that use Hyper-V WMI APIs from the v1 namespace to the v2 namespace.

MSDN Samples

Hyper-V virtual machine migration sample
Hyper-V virtual Fiber Channel sample
Hyper-V planned virtual machines sample
Hyper-V application health monitoring sample
Virtual hard disk management sample
Hyper-V replication sample
Hyper-V metrics sample
Hyper-V dynamic memory sample
Hyper-V Extensible Switch extension filter driver
Hyper-V networking sample
Hyper-V resource pool management sample
Hyper-V recovery snapshot sample

Samples From Blogs

Adding a Network Adapter To A VM Using The Hyper-V WMI V2 Namespace
Connecting a VM Network Adapter To A Switch Using The Hyper-V WMI V2 Namespace
Changing The MAC Address Of NIC Using The Hyper-V WMI V2 Namespace
Removing a Network Adapter To A VM Using The Hyper-V WMI V2 Namespace
Attaching a VHD To A VM Using The Hyper-V WMI V2 Namespace
Removing a VHD From A VM Using The Hyper-V WMI V2 Namespace
Creating a VM using the Hyper-V WMI V2 Namespace