I would look at the the vSphere Web Services SDK if you really want to roll up your sleeves,,, or if you need to do this in a jiffy consider using PowerCLI.. Sample code is included in all of our kits, and we also have code posted on our Code Central site "Sample Code"