Solved

Search for VMDK in all datastores

Posted on 2013-12-27
10
3,151 Views
Last Modified: 2013-12-31
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
Comment
Question by:jskfan
10 Comments
 
LVL 119

Assisted Solution

by:Andrew Hancock (VMware vExpert / EE MVE^2)
Andrew Hancock (VMware vExpert / EE MVE^2) earned 251 total points
ID: 39743027
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
 

Author Comment

by:jskfan
ID: 39743060
Do I need to login to each ESX server via SSH and run the command you posted ?
0
 
LVL 40

Assisted Solution

by:coolsport00
coolsport00 earned 83 total points
ID: 39743070
@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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 42

Assisted Solution

by:paulsolov
paulsolov earned 83 total points
ID: 39743107
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
 
LVL 8

Assisted Solution

by:piyushranusri
piyushranusri earned 83 total points
ID: 39743116
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
 
LVL 119

Assisted Solution

by:Andrew Hancock (VMware vExpert / EE MVE^2)
Andrew Hancock (VMware vExpert / EE MVE^2) earned 251 total points
ID: 39743351
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
 

Author Comment

by:jskfan
ID: 39744712
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
 

Author Comment

by:jskfan
ID: 39744717
I guess powercli will use : Get-VM  command
0
 
LVL 119

Accepted Solution

by:
Andrew Hancock (VMware vExpert / EE MVE^2) earned 251 total points
ID: 39744800
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
 

Author Closing Comment

by:jskfan
ID: 39748622
Thank you
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
This article outlines why you need to choose a backup solution that protects your entire environment – including your VMware ESXi and Microsoft Hyper-V virtualization hosts – not just your virtual machines.
Teach the user how to install ESXi 5.5 and configure the management network System Requirements: ESXi Installation:  Management Network Configuration: Management Network Testing:
Teach the user how to configure vSphere Replication and how to protect and recover VMs Open vSphere Web Client: Verify vsphere Replication is enabled: Enable vSphere Replication for a virtual machine: Verify replicated VM is created: Recover replica…

778 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question