Solved

Search for VMDK in all datastores

Posted on 2013-12-27
10
3,493 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
10 Comments
 
LVL 121

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
Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.

 
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 121

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 121

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

Independent Software Vendors: 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!

Question has a verified solution.

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

Last article we focus in how to VMware: How to create and use VMs TAGs – Part 1 so before follow this article and perform the next tasks, you should read the first article how to create the TAG before using them in Veeam Backup Jobs.
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Teach the user how to edit .vmx files to add advanced configuration options Open vSphere Web Client: Edit Settings for a VM: Choose VM Options -> Advanced: Add Configuration Parameters:
Teach the user how to join ESXi hosts to Active Directory domains Open vSphere Client: Join ESXi host to AD domain: Verify ESXi computer account in AD: Configure permissions for domain user in ESXi: Test domain user login to ESXi host:

728 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