Link to home
Start Free TrialLog in
Avatar of Ajay Pathak
Ajay PathakFlag for India

asked on

Getting associated DAtastore for VM

Can anyone give me the script for getting the datastore information for list of VMs?

I have PowerCLI module installed but not getting the cmdlet for getting this information.
Avatar of Carlos Ijalba
Carlos Ijalba
Flag of Spain image

You are better off using RVTOOLS:


As you can run it via GUI or via CLI, to generate such information.
slightly different then what you want, but you can use Get-VM and specify a data store and it will show all the guests in that data store

so if you have a data store called DS1 for example, you could do Get-VM -Datastore DS1

http://pubs.vmware.com/vsphere-50/index.jsp#com.vmware.powercli.cmdletref.doc_50/Get-VM.html
You do know, that you can also use vCenter Server - Map function, to map VMs to Datastores ?

and also show all the VMs, against datastore, right click and Export to Excel without scripts or additional tools ?

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

and then use the VMware Community Pack which includes the scripts you will need to use to generate your datastores map to VMs.

http://www.virtu-al.net/featured-scripts/vmware-powerpack/
ASKER CERTIFIED SOLUTION
Avatar of Ajay Pathak
Ajay Pathak
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ajay Pathak

ASKER

asked for getting oneliner for datastore info. for VMs.

Then found the solution as suing Get-datastore cmdlet for PowerCLI