Manipulate Hyper-V from .NET

Jason Whitehorn picture Jason Whitehorn · Nov 15, 2009 · Viewed 19.6k times · Source

Are there any means for a .NET application to create, delete, start, and stop Hyper-V virtual machines?

I would like to create an automated means of starting and stopping (the create & delete are bonus) virtual machines from a C# application. I figured that (atleast) there would be a means of doing this via P/Invoke, but I cannot find anything discussing how to do this.

Any links to some good walkthroughs or documentation would be preferable.

Answer

anelson picture anelson · Nov 15, 2009

Much of the Hyper-V automation is through WMI. WMI isn't explicitly a .NET API, but it's pretty easy to work with from .NET.

The Hyper-V WMI API docs are at http://msdn.microsoft.com/en-us/library/cc136992(VS.85).aspx