VMware {code} Community
twtb
Contributor
Contributor

c# get VM list

How can I get a list of all VM's on a VMWare host or vCenter host using C#?

I've searched for example code but I didn't find anything usefull.

0 Kudos
3 Replies
bulletprooffool
Champion
Champion

Hi,

Have you had a look at project Onyx in the VMware labs?

enumerting VMs would be one of the simpler tasks, so I am guessing that you will have several questions like this coming up if you are coding some c# app - Onyx should ease the process.

Simple usage guide at http://www.get-virtual.info/2011/02/16/script-of-the-day-quick-and-easy-vmware-powershell-scripts/ (just change the dropdown from  Powershell to C#)

Alternatively use PowerCli (where it will be as simple as Get-VM)

Or lastly, you could use Powershell in your C# code:

try :

http://www.codeproject.com/KB/cs/HowToRunPowerShell.aspx for running Powershell code directly in c#.

finally, a similar thread to this - with a solution to your question:

http://communities.vmware.com/thread/303927

One day I will virtualise myself . . .
twtb
Contributor
Contributor

Isn't it possible to do it directly with the vSphere Web Services SDK in C# without PowerCLI?

0 Kudos
bulletprooffool
Champion
Champion

Yes, for sure - as I said before, use Project onyx to generate code snippets, then just clean it up.

Alternatively . . lookie here:

http://communities.vmware.com/thread/127126

One day I will virtualise myself . . .
0 Kudos