Hello PowerCLI gurus!
Could you please help me with the following task:
Let's imagine, I have a list of VMs. I need to have a report for each of these VMs, which will show me on which host these VM's currently working, on which datastore / LUN files of VMs are located and what type of path selection has chosen. It would be great a possibility to withdraw these data to CSV file.
Thank you in advance.
You could try something like this.
Note the script assumes VMFS datastores.
$vmNames = Get-Content vmnames.txt
Get-VM -Name $vmNames -PipelineVariable vm | %{
Get-View -Id $_.DatastoreIdList |
Select @{N='VM';E={$vm.Name}},
@{N='Datastore';E={$_.Name}},
@{N='LUN';E={$_.Info.Vmfs.Extent[0].DiskName}},
@{N='PathPolicy';E={Get-ScsiLun -CanonicalName $_.Info.Vmfs.Extent[0].DiskName -VmHost $vm.VMHost | select -ExpandProperty MultiPathPolicy}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello LucD!
First of all, thank you for your reply and help. The output contain information about the VM, Datastore, LUN. However, the PathPolicy is fully empty. How do you think, where is the problem should be?
P.S. VMFS on all datastores in our infrastructure.
Are you by any chance using EMC PowerPath?
Does this display the policy?
$vmNames = Get-Content vmnames.txt
Get-VM -Name $vmNames -PipelineVariable vm | %{
Get-View -Id $_.DatastoreIdList |
Select @{N='VM';E={$vm.Name}},
@{N='Datastore';E={$_.Name}},
@{N='LUN';E={$_.Info.Vmfs.Extent[0].DiskName}},
@{N='PathPolicy';E={(Get-EsxCli -VMHost $vm.VMHost).storage.nmp.device.list($_.Info.Vmfs.Extent[0].DiskName) | Select -ExpandProperty PathSelectionPolicy}}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Mmm.. I am not sure, I guess not.
Yeah! This is what working for me. Thank you very much!
