title: What to specify for Local ManagementScope
body: <p>I am trying to connect (locally) to get a list of virtual machines and their properties.  I have hacked some code I found, but my code is failing to connect so I can only assume that the connection string is wrong.  </p>
  
  <p>Using Server 2012, Hyper-V</p>
  
  <pre><code>private void listVirtualMachines() {
  
      ManagementScope manScope = new ManagementScope(@"\\LOCALHOST\root\cimv2");
  
          if (manScope.IsConnected) {
  
              ObjectQuery queryObj = new ObjectQuery("SELECT * FROM Msvm_ComputerSystem");
  
              // connect and set up our search
              ManagementObjectSearcher vmSearcher = new ManagementObjectSearcher(manScope, queryObj);
  
              ManagementObjectCollection vmCollection = vmSearcher.Get();
  
              // loop through the machines
              foreach (ManagementObject vm in vmCollection) {
                  // display VM details
                  LogString(vm["ElementName"].ToString());
                  LogString(vm["EnabledState"].ToString());
                  LogString(vm["Description"].ToString());
              }
          } else {
              //WE END UP HERE EVERY TIME!
              LogString("Cannot Connect to ManagementScope!");
          }
  
      } //funct
  </code></pre>