Below is a script that does exactly what I want but I need to make some changes to it and need help adding the needed lines. I will like to add a line to show the LUN ID's for each storage LUN on each hosts and also add a line for WWN names of the hosts as well. Below is the script.
Thanks.
$VmInfo=ForEach ($Datacenterin (Get-Datacenter|Sort-Object-PropertyName)) {
ForEach ($Clusterin ($Datacenter|Get-Cluster|Sort-Object-PropertyName)) {
ForEach ($VMin ($Cluster|Get-VM|Sort-Object-PropertyName)) {
ForEach ($HardDiskin ($VM|Get-HardDisk|Sort-Object-PropertyName)) {
""|Select-Object-Property@{N="VM";E={$VM.Name}},
@{N="VM CPU#";E={$vm.ExtensionData.Config.Hardware.NumCPU/$vm.ExtensionData.Config.Hardware.NumCoresPerSocket}},
@{N="VM CPU Core#";E={$vm.NumCPU}},
@{N="Datacenter";E={$Datacenter.name}},
@{N="Cluster";E={$Cluster.Name}},
@{N="Host";E={$vm.VMHost.Name}},
@{N="Host CPU#";E={$vm.VMHost.ExtensionData.Summary.Hardware.NumCpuPkgs}},
@{N="Host CPU Core#";E={$vm.VMHost.ExtensionData.Summary.Hardware.NumCpuCores/$vm.VMHost.ExtensionData.Summary.Hardware.NumCpuPkgs}},
@{N="Hard Disk";E={$HardDisk.Name}},
@{N="Datastore";E={$HardDisk.FileName.Split("]")[0].TrimStart("[")}},
@{N="VMConfigFile";E={$VM.ExtensionData.Config.Files.VmPathName}},
@{N="VMDKpath";E={$HardDisk.FileName}},
@{N="VMDK Size";E={($vm.extensiondata.layoutex.file|?{$_.name-contains$harddisk.filename.replace(".","-flat.")}).size/1GB}},
@{N="Drive Size";E={$HardDisk.CapacityGB}}
}
}
}
}
$VmInfo|Export-Csv-NoTypeInformation-UseCulture-Path"c:\scripts\reports\report.csv"