VMWare Script to audit virtual servers

Associate
Joined
24 May 2011
Posts
216
As I am now managing a large VMWare infrastructure, been doing a lot of scripts .. here is one for anyone who wishes to use it

some script I have knocked up to audit a esx or esxi hosts to see what virtual machine is running

tested on 3.x and 4.x not on 5.x

you will need to install the vmware vsphere cli in order to run the script

run via command line

auditvm.pl --server <esxi/esx server> --username <username> --password <password> --entity VirtualMachine

will print out info esx/esxi host and what virtual machine is on it and if it is on or off

the results is written to a fiile audit.txt


Example of output

VM Server Host Name: xxxxxxxxxxxxxxxxxxxxxxxxx

Server Product Name: VMware ESXi
ESX Version: 4.1.0
ESX Build: 260247
Server Type: embeddedEsx

Virtual Machine Summary
-------------------------------------------------

yyyyy is OFF.
zzzzz is ON

-------------------------------------------------

source code http://pastebin.com/riLqgjqC
 
Last edited:
if you want to you can wrap this around a batch file ..

have a list of esxi servers in text file and then using the batch file read each line of the text file with servername and call the perl script

c:
cd\
cd Program Files (x86)
cd vmware
cd "vmware vsphere cli"
cd bin

for /f %%i in (servers.txt) do call :AUDITVM %%i


:AUDITVM
test1.pl --server %1 --username %2 --password %3 --entity VirtualMachine
 
Back
Top Bottom