am trying to get the report of VM and it's details.
I have written a powercli script which would find VM name, IP address, Poweron status and snapshot list. But i have no idea how to find the datastore associated with the VM.
How to get VM name and it's associated datastore?
One way of doing that is
Get-VM | Select name,@{N="DS";E={[string]::Join(',',(Get-View $_.DatastoreIdList | %{$_.Name)}}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
another way would be like this . this will also detail the host information
Connect-VIServer
44.128.164.101
Get-VM
| Select Name, @{N="Cluster";E={Get-Cluster -VM $_}}, `
@{N
="ESX Host";E={Get-VMHost -VM $_}}, `
@{N
="Datastore";E={Get-Datastore -VM $_}}