Hi,
I need three scripts to collect ESX storage information as given below
1. Storage hardware info --> to collect info about SCSI controller and HBA cards.
ESX Name | SCSI controller | HBA1 | HBA2
Expected output
ESX Name | SCSI (Model,Bios version,serial Number, Raid config) | HBA1(Model, Firmware version, serial number,WWPN) | HBA2(Model, Firmware version, serial number,WWPN)
Note : Need info about all SCSI controllers and HBA's in the ESX box, so additional columns could be added as required.
2.Storage usage report ---> Storage usage report including local filesystem storage and also SAN volumes.
ESX name | Filesystem | Size | Used | Avail | Use% | Mount Point | Extents
Note : Need all sizes in GB. Extents are applicable for SAN datastores and just need the extent DiskID like vmhba1:1:1
3. San disk information -->To collect information about San Disk
Disk ID | Lun ID | Disk Size | Make/Model | Path(s) | Policy | Active HBA WWPN
Expected Output
vmhba1:1:1 | 0110 | 130G | EMCxxxx | 4 | Fixed | xxxxxxxxxxxxxxx
Thanks Luc. It works!
Luc,
At Last when export the report to CSV file, the vaules of $totalsize and $totalusize does not get copied in csv sheet. How do i export the values of $totalsize and $totalusize at the end of the CSV File?
.........
@{N="Used%";E={"{0:P1}" -f $usedPerc}},
@{N="Mount point";E={$_.Path}}
$totalsize += ($totalsize + $sizeGB)
$totalusize += ($totalusize + $usedGB)
}
$totalsize
$totalusize
} | Export-csv "c:\test.csv"
}
The next script exports the $totalsize and $totalusize to the .csv file also. I made some other changes too. E.g. the calculation of the total sizes was not correct.
Get-Cluster | ForEach-Object { $Cluster = $_ $dsTab = @{} $TotalSizeGB = [double]0 $TotalUsedSizeGB = [double]0 $esxImpl = $cluster | Get-VMHost | Select-Object -First 1 $ds = $esxImpl | Get-Datastore | ForEach-Object {$dsTab[$_.Name] = $_} $esxImpl | Get-VMHostStorage | ForEach-Object { $_.FileSystemVolumeInfo | ForEach-Object { $SizeGB = $_.Capacity/1GB $TotalSizeGB += $SizeGB $UsedGB = ($_.Capacity/1MB - ($dsTab[$_.Name]).FreeSpaceMB)/1KB $TotalUsedSizeGB += $UsedGB $UsedPerc = $UsedGB / $SizeGB $AvailGB = ($dsTab[$_.Name]).FreeSpaceMB/1KB $ds = Get-View $dsTab[$_.Name].Id $_ | Select-Object -Property @{N="ESX Name";E={$esxImpl.Name}}, @{N="Cluster Name";E={$Cluster}}, @{N="FS Name";E={$_.Name}}, @{N="Type";E={$_.Type}}, @{N="SizeGB";E={"{0:N1}" -f $sizeGB}}, @{N="UsedGB";E={"{0:N1}" -f $UsedGB}}, @{N="AvailableGB";E={"{0:N1}" -f $AvailGB}}, @{N="Used%";E={"{0:P1}" -f $UsedPerc}}, @{N="Mount point";E={$_.Path}},TotalSizeGB,TotalUsedSizeGB } } "" | Select-Object -Property @{N="Cluster Name";E={$cluster}}, @{N="TotalSizeGB";E={"{0:N1}" -f $TotalSizeGB}}, @{N="TotalUsedSizeGB";E={"{0:N1}" -f $TotalUsedSizeGB}} } | Export-csv -Path "DatastoreSizes.csv" -NoTypeInformation -UseCulture
Regards, Robert