Depends on the language you're looking to write the script in but here is an example written in PowerCLI: http://www.virtu-al.net/2010/02/23/who-created-that-vm/
You may want to post your question directly onto a SDK of choice or if it's general, look at posting in Developer forums - http://communities.vmware.com/community/developer
=========================================================================
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".