PowerShell script to remove virtual machine from VMWare Infrastructure
Forget about the trip to Las Vegas I mentioned before, I started to like VMWare VI Tookkit the more I use it!
You just need to cultivate a habit, every time if you need to repetitively doing something, you should ask yourself if you can do it with PowerShll. More likely than not, the answer is YES, WE CAN!
Like I have a bunch of cloned vm box acting as a backup to our MOSS staging environment. We are tight on resource and so we decided to delete all the clones. Instead right click one by one, you can use the below script. Thanks Hal's comment to my previous post, it's now much simpler!
get-vm clone*|remove-vm -deletedfromdisk
But I do notice that after I remove vm this way, I got something like
clone-xyz(orphaned), you may have to add remove-inventory but I wasn't able to test this part!
Similarly you could do:
get-vm xyzmoss* |shutdown-vmguest
and
get-vm xyzmoss* |start-vm