Hi,
Can anyone help? I'm looking to create a report which will show each datastores lunID and datastore name, list the VMs belonging to those datastores and the name of the VCenter at the top of the report. I've tried a few combinations however getting the lunID has proved the most difficult. Any help gratefully appreciated.
Thanks
If you are using only LUNs an easy way to get the canonical name is:
get-datastore | Select-Object Name,@{Name="CanonicalName";expression={$_.extensiondata.info.vmfs.extent.diskname}}
I do not understand your requirement regarding the vCenter Name, but for everything else
get-datastore | foreach {($MyDatastore = $_)} | get-vm | Select-Object @{Name="Datastore";expression={$MyDatastore}},@{Name="CanonicalName";expression={$MyDatastore.extensiondata.info.vmfs.extent.diskname}},Name
If you are using only LUNs an easy way to get the canonical name is:
get-datastore | Select-Object Name,@{Name="CanonicalName";expression={$_.extensiondata.info.vmfs.extent.diskname}}
I do not understand your requirement regarding the vCenter Name, but for everything else
get-datastore | foreach {($MyDatastore = $_)} | get-vm | Select-Object @{Name="Datastore";expression={$MyDatastore}},@{Name="CanonicalName";expression={$MyDatastore.extensiondata.info.vmfs.extent.diskname}},Name
Hi,
Can you please try the following? Runs fine in my Lab environment. Due to non availability of resources could not test extensively.
$datastores = Get-Datastore
$details = @()
$ErrorActionPreference = 'SilentlyContinue'
Foreach ($datastore in $datastores) {
$data = New-Object -TypeName PSObject | Select Name, LunId, VMs
$data.LunId = (Get-ScsiLun -Datastore $datastore | Select -Unique).CanonicalName.Split('.')[1]
$data.Name = $datastore.Name
$data.VMs = (Get-VM -Datastore $datastore.Name).Name
$details += $data
}
$details
Please let me know if you face any issues and I can fine tune
THanks. I'll try this early Tuesday morning and let you know How it goes.