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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Carlos IjalbaIT Systems DirectorCommented:
You are better off using RVTOOLS:

As you can run it via GUI or via CLI, to generate such information.
Seth SimmonsSr. Systems AdministratorCommented:
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
Andrew Hancock (VMware vExpert / EE MVE^2)VMware and Virtualization ConsultantCommented:
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.

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

and then use the VMware Community Pack which includes the scripts you will need to use to generate your datastores map to VMs.
aspathakAuthor Commented:
I have got the one Liner Get-datastore -VM $VM1,$VM2.

can any one tell me how to get the info from list of servers in notepad. I know gc will fetch the info from notepad file but how to associate with this oneliner.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
aspathakAuthor Commented:
asked for getting oneliner for datastore info. for VMs.

Then found the solution as suing Get-datastore cmdlet for PowerCLI
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.