leitsuhsu
Contributor
Contributor

Find virtual machine's datastore

Hi

Does someone know how to write a script to list the datastore namse that each disk reside on?

Thanks

0 Kudos
4 Replies
bayupw
Leadership
Leadership

Hi

See below 3 links

To list VM, cluster, hosts, folders, vmdk file path

Virtual Machine VMDK file report with PowerCLI | vNiklas Virtualization blog

PowerCLI List all VMDK disks and what datastore they are on | Virtual Me

Thanks,

Bayu

Bayu Wibowo | VCIX6-DCV/NV
Author of VMware NSX Cookbook http://bit.ly/NSXCookbook
https://github.com/bayupw/PowerNSX-Scripts
https://nz.linkedin.com/in/bayupw | twitter @bayupw
0 Kudos
naiksidd
Enthusiast
Enthusiast

hi try this,

$vm = Get-vm <vmname>

$vhdds = $vm | get-harddisk

foreach($vhdd in $vhdds)

{

  $hddlabel = $vhdd.extensionData.DeviceInfo.Label

  $hddSize = $vhdd.CapacityGB;

  $hddFilePath = $vhdd.FileName

}

this is same as in the links but simpler version, you can print or export the variables as you need.

for FilePath if you only need Datastore,

do

$hddFilePath =  $hddFilePath.Split(" ")[0]

hope this helps

0 Kudos
online11
Contributor
Contributor

Can you add naa.id on this script? Thanks

0 Kudos
N0bo
Enthusiast
Enthusiast

You rather get RVtools export .It has all this info in nice excel file Smiley Happy

You can get it from here RVTools - Home

0 Kudos