Just Another IT Blog

It's time to share some of my experiences, crazy ideas, tips and tricks !!!

Post Page Advertisement [Top]

I have to admit since I started playing with PowerCLI I’ve been enjoying it more and more.

A few weeks ago I needed to delete 50 VMs from the environment and I realized I would give the script a shot.
Of course I could do that through Virtual Center, but it would take some time to do it manually.

So, here’s my script which deleted all the 50 VMs in about 08 minutes ; )

Assuming that you have a txt file with your guest’s name one per line.
Mine was c:\temp\servers.txt (replace this on the script for you file name)

Open PowerCLI
Connect on VC: Connect-VIServer –Server “your_VC_goes_here”
Get-Content c:\temp\servers.txt | foreach { Remove-vm $_ -DeleteFromDisk -Confirm:$false }

Have a good one

Bottom Ad [Post Page]