I wonder if there is a way to write a script that finds Datastore name if I have VM name and VM disk SCSI number (0:2, for example)?
Thanks a lot!
Try something like this
Get-VM | Get-HardDisk | Select @{N="VM";E={$_.Parent.Name}}, Name,@{N="Datastore";E={$_.Datastore}},@{N="SCSI Id";E={[string](Get-ScsiController -Harddisk $_).ExtensionData.BusNumber + ":" + [string]$_.UnitNumber}}
Luc,
However, when I am running your script it does not seem grabing "UnitNumber" (SCSI Id always 0: ) and Datastore field is always blank as well.
Any suggestions?
Thanks,
qwert
Which PowerCLI version are your running ?
Do a
Get-PowerCLIVersion
And your VMs are on VMFS datastores, not NFS I assume ?
I have VMware vSphere PowerCLI 5.0 build 435427
Actually, I am using VMs on both storage types - VMFS and NFS. Is it matter?
Thank you!
Afaik I does, on a NFS datastore that script I gave will not work.
Not that it matters in this case, but you should perhaps consider upgarding to PowerCLI 5.1