• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3999
  • Last Modified:

Search for VMDK in all datastores

I have deleted a VM for VSphere client , I was not sure if I deleted it from disk.
I would like to search for it in all datastores. is there an easy way to find it so that I can delete the related files.

Thanks
0
jskfan
Asked:
jskfan
6 Solutions
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
The VMware Community Pack has a script which can show unallocated or orphanced VMDK files, e.g. VMDK (virtual machine disks) which are not connected to any VM in the inventory.

or using PowerCLI

# this example will list all files and subfolders that starts with Win7
# inside the datastore with name datastore1.

ls vmstores:\myServer@443\Datacenter\datastore1\Win7*

Open in new window


or you could login to the server via SSH/Console, and use the ls command
0
 
jskfanAuthor Commented:
Do I need to login to each ESX server via SSH and run the command you posted ?
0
 
coolsport00Commented:
@jskfan - no, if you log in to PowerCLI, your first command would be:
Get-ExecutionPolicy

If Restricted is shown, type:
Set-ExecutionPolicy RemoteSigned

Run Get-ExecutionPolicy again to verify the policy changed to RemoteSigned

Next, connect to your vSphere infrastructure - specifically, to vCenter by typing:
Connect-VIServer vcenterServerNameOrIP

Then, you can run Andrew's cmd and it will be run against your whole infrastructure that is connect to that particular vCenter Server.

Regards,
~coolsport00
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Paul SolovyovskyCommented:
another way to do this is to install rvtools (robware.net).  Great tool and one of the columns has a health tab which includes "zombie" VMs, basically VMs that are on the datastore but are not registered.  This is a easy way to get what you need.

Also has a lot of good info like snapshots, space left on volumes, etc..
0
 
piyushranusriCommented:
please browse these related URL

1. http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1005049
2.http://kevinmarkwardt.com/orphans/ ( a script to create a list of all of the vmdk’s on the current VM’s and then it will scan all of the datastores and attempt to match them up)


please share the output
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
If you have limited experience of PowerCLI, I would recommend the VMware Community Pack, which is almost designed ready to go with limited PowerCLI scripting abilities.
0
 
jskfanAuthor Commented:
Is this command Powercli ?

ls vmstores:\myServer@443\Datacenter\datastore1\Win7*

it looks like Linux

I have installed powercli. I am not sure which is better powercli or vcli..I believe vcli uses Linux commands while powercli uses Microsoft commands
0
 
jskfanAuthor Commented:
I guess powercli will use : Get-VM  command
0
 
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
Yes, it's a VMware command, it actually "pipes the command" to the ESXi console.

I would recommend using the following, also VMware recommends the use of PowerCLI, which is PowerShell interface with vSphere-specific additions.

http://communities.vmware.com/community/vmtn/server/vsphere/automationtools/powercli

One of the simplest PowerCLI examples, and something which is actually extremely useful on its own, is the Get-VM cmdlet. Which lists VMs.

PowerCLI can be a bit overwhelming to use,  But it can be enhanced with a nice toolset and a library of preconfigured scripts to jump-start your mass changes, which is possible with PowerGUI

http://powergui.org/index.jspa

again, if you are not familiar with PowerCLI use the

VMware Community Pack

http://www.virtu-al.net/featured-scripts/vmware-powerpack/
0
 
jskfanAuthor Commented:
Thank you
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now