VMware Cloud Community
thanosazlin
Contributor
Contributor

vsphere vmware.vim.dll on visual c sharp app

figured out today that i could best suit the app i am developing by using vmware.vim.dll instead of calling process to run an external command. so i d/l the vsphere powercli and add vmware.vim.dll and added to my C# project, but i am having trouble finding good API documentation. i am only looking for a bit of quick code that will connect to my vcenter host then report back all ESX host names and version of ESX on all hosts that the vCenter server manages? I manage to connect to my vcenter host, and i was messing around with FindEntityViews but couldn't figure out the best method to get the info i need.

VimClient client = new VimClient();

client.Login("10.10.1.1","testdomain\admin","password");

i then want to just have a string variable to hold all the output from whatever API call will get me all ESX host names and versions that the vCenter server manages?

Tags (2)
0 Kudos
1 Reply
thanosazlin
Contributor
Contributor

i figured it out myself Smiley Happy, i incorrectly had the login entry coded wrong above too. here is what i ended up with

VimClient

client = new VimClient();

client.Login(

"https://10.10.1.1/sdk", @"test\admin", "password");

NameValueCollection filter = new NameValueCollection();

IList<EntityViewBase> esxList = client.FindEntityViews(typeof(HostSystem), null, null, null);

foreach (HostSystem host in esxList)

{

string hostname = host.Name.ToString();

string version = host.Summary.Config.Product.FullName.ToString();

MessageBox.Show(hostname);

MessageBox.Show(version);

}

and it returns the esx host names and version Smiley Happy

0 Kudos