Script for automating vmware
Posted on 2008-10-24
We have two VMware ESX servers in production, and also use the Virtual Center for management. I downloaded and installed the vmware VI3 toolkit and Windows Powershell so that we can automate such things as deleting and cloning our virtual servers. I can open the toolkit command window and execute the commands with no problem, but how would I make a script that I can schedule? I tried making one in notepad and giving it a ps1 extension, but the only thing that happens is a command window pops up then goes away immediately. I am totally new to scripting with powershell/vmware. The bad thing is, I can't even see what is going on because I don't know how to "pause" the script to see what is happening.
Here is what I put into notepad and saved as script.ps1 :
connect-esx -server 192.168.1.249 -user root -password vmware
remove-vm (get-vm "eservice clone") -deletefromdisk