VMware Cloud Community
plq
Contributor
Contributor
Jump to solution

How to interrogate an ESXi box from a VBScript

Hi Folks,

What technologies might by used to programmatically get information from an ESXi 4 box from a remote computer ?

I've been scouring the forums for a few days but not really getting very far. I saw that the CIM stuff might be supported by esxi, so I was wondering if it was possible to use Windows WMI scripting to access esxi.

Also I saw that each esxi box has a https interface - given the root username and password is there a way to get system info via https ?

Any other ways to query esxi ? I'm definitely querying from the MS platform so please any pointers, threads, blogs, clues - anything - would be much appreciated..

thanks

Paul

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

What "data" are you trying to extract? If it's hardware information, then yes, the CIM API is what you'll want to use. If you want to query information out of your ESXi host such as what VMs are running, how many vCPU/vMEM each has, host information or configuration you will want to use the VMware vSphere API. The API itself is exposed as a standard web service and there are various language bindings that are offered such as vSphere SDK for Perl (Perl bindings), PowerCLI (Windows PowerShell bindings), VI Java (Java Bindings), vSphere SDK for C# (C# webservices bindings), etc.

If you want to use any other programming or scripting language than the ones offered, then you'll need to create your own client side bindings which is not for beginners, it requires quite a bit of work and you will also need to ensure that the language can talk to SOAP/WebServices engines and create the appropriate calls/etc.

If you're new the VMware API/SDKs, you'll want to take a look at this document first - http://communities.vmware.com/docs/DOC-7270

There is also a VMware Developer Forums with all the various language support, documentation, sample code and getting started guides at - http://communities.vmware.com/community/developer

To answer your question, vbscript is probably not what you'll want to use, it probably won't even support what you need. If you're coming from a Windows background, take a look at using PowerShell and PowerCLI

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

View solution in original post

0 Kudos
5 Replies
lamw
Community Manager
Community Manager
Jump to solution

What "data" are you trying to extract? If it's hardware information, then yes, the CIM API is what you'll want to use. If you want to query information out of your ESXi host such as what VMs are running, how many vCPU/vMEM each has, host information or configuration you will want to use the VMware vSphere API. The API itself is exposed as a standard web service and there are various language bindings that are offered such as vSphere SDK for Perl (Perl bindings), PowerCLI (Windows PowerShell bindings), VI Java (Java Bindings), vSphere SDK for C# (C# webservices bindings), etc.

If you want to use any other programming or scripting language than the ones offered, then you'll need to create your own client side bindings which is not for beginners, it requires quite a bit of work and you will also need to ensure that the language can talk to SOAP/WebServices engines and create the appropriate calls/etc.

If you're new the VMware API/SDKs, you'll want to take a look at this document first - http://communities.vmware.com/docs/DOC-7270

There is also a VMware Developer Forums with all the various language support, documentation, sample code and getting started guides at - http://communities.vmware.com/community/developer

To answer your question, vbscript is probably not what you'll want to use, it probably won't even support what you need. If you're coming from a Windows background, take a look at using PowerShell and PowerCLI

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

If you find this information useful, please award points for "correct" or "helpful".

0 Kudos
admin
Immortal
Immortal
Jump to solution

You've seen the resources on this page right?

http://www.vmware.com/support/pubs/sdk_pubs.html

Rick Blythe

Social Media Specialist

VMware Inc.

J1mbo
Virtuoso
Virtuoso
Jump to solution

The client operates using SOAP over HTTPS. I don't know if you can script this with VBA?

However vmware's vSphere CLI can be installed on Windows and provides an official perl based scripting interface. There are many high-quality scripts in Perl for vmware already, for example those by William Law: http://communities.vmware.com/docs/DOC-9852

Note that most of it is however read-only if you have free-licensed ESXi (for example, you cannot power on a VM or take a snapshot). Of course you can work around this by scripting via SOAP directly, emmulating the vSphere client in effect.

HTH

http://blog.peacon.co.uk

Please award points to any useful answer.

plq
Contributor
Contributor
Jump to solution

Excellent, so C# with web services queries sounds like the way to go.. let me download all that stuff and see if I can get it working.

And yes, I really want to extract system information, cpu. memory, disk, serial number, make, model, info on each guest vm, whatever i can get.

thanks very much for posting. I'll report back here in a day or so.

0 Kudos
plq
Contributor
Contributor
Jump to solution

Well after a bit of a fight I worked out how to compile the c# samples.

Just one question, as I can't easily get the samples working although they are compiling ok.

Lets say I have an esxi host machine at 10.5.0.98 - would the following be a sensible command line for those samples ?

https://10.5.0.98/sdk root password

Or would it be https://vspherehst/sdk root password ?

I'm trying the "connect" sample and its just throwing back a usage screen as pasted below. Other samples seem to do the same.

I guess I should raise another thread for this in the dev area, but since you guys are listening, I thought I'd run it by you.

thanks

Paul

Begin Log.

Common .Net Options :

--help < type String >

Display user information for the script

--sessionfile < type String >

File containing session ID/cookie to utilize

--portnumber < type String, default 443>

Port used to connect to server

--url < type String >

VI SDK URL to connect to

--username < type String >

Username to connect to the host

--ignorecert < type String >

Ignore the server certificate validation

--servicepath < type String >

Service path used to connect to server

--config < type String >

Location of the VI perl configuration file

--server < type String >

0 Kudos