title: Create VM in ESXi using C# and the vSphere API .NET library
body: <p>How can I create a new VM in VMware vSphere ESXi using C# .NET?</p>
  
  <p>I am using the vSphere API .NET Library VMware.Vim.dll from PowerCLI.
  The following code explains the context.</p>
  
  <pre><code>using VMware.Vim;
  public class VmCreator{
      VimClient Client = new VimClientImpl();
  
      public VmCreator(){
          Client.Connect("https://hostName/sdk");
          Client.Login("username", "password");
  
          // Create new VM goes here
      }
  }
  </code></pre>
  
  <p>VMware themselves say that you can develop .NET applications for creating, customizing, or managing vSphere inventory objects using VMware.Vim.dll, so I thought it would be a good way to do it, but I cannot find any documentation at all.</p>
  
  <p>Maybe there is a better/easier way to create ESXi VMs from a C# .NET project?</p>