VMware

Find Orphaned VMDK's

VERSION 4 Published

Created on: Aug 11, 2008 5:55 AM by MorDrakka - Last Modified:  Jun 17, 2009 1:25 PM by MorDrakka


(This script is for ESX 3.01, to find snapshots on 3.5 and above change the script en the names it searches for!!!!!)

Hi,

This script will find all orphaned vmdk's on all your virtual centers (we have more than one :p).

Our VM's are being administered by mutliple people. When removing a virtual disk, sometimes people forget to delete the vmdk file itself.

This script asks the virtual center what the disk are of each VM and puts this into an array. After this, it reads all files on all datastores. If the file is a vmdk file, it will check wheter this file is in the array. If it's not, you've found a orphaned vmd.

Output is being written to a file. Script displays the Host off which files are being enumerated(For waiting purposes).

Variables whcih have to be submitted:

$arrayVC = "YourVirtualCenter"
$OutputFile = "C:\OrphanedVMDK.txt"

Greetings,


Ad van Bokhoven


This document was generated from the following thread: Find Orphaned VMDK's

Attachments:
Average User Rating
(2 ratings)




Aug 15, 2008 8:00 PM johnlennon  says:

Good scripts, however it doesn't work well as it mistakenly reports VMDK from VMs that have a snapshot.

Jan 30, 2009 9:41 AM Funtoosh  says:

I would suggest everyone to be careful before running this script. It will report even snapshot vm’s vmdk file as orphaned one. I lost one of my prod vm and had hard time reconfiguring it back.

Feb 13, 2009 9:17 AM forbes  says:

Does anyone know how to add the disk sizes as well? I'd like to show how much space we could recover.

Also, it says at the top that this is for 3.0 hosts and for 3.5 hosts you should change the filenames. Exactly how do these differ between versions?

Thanks, Forbes.

Forbes Guthrie
http://www.vreference.com

Feb 14, 2009 6:08 PM esxfan  says: in response to: forbes

Extended the scipt. It works for me. http://communities.vmware.com/blogs/esxfan

More by MorDrakka

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities