timmp
Enthusiast
Enthusiast

Thanks for these great scripts. I am using one of these scripts in a datacenter with multiple clusters. When the information is output via html, it adds multiple instances of the clusters. Is there a way to run this and designate the cluster to gather the desired datastore information? I have tried modifying to no avail. Also, can it be setup to do a sort by the HostLun or VolumeName? Here is my modified script:

  1. ---- Hosts Storage Information ----

if ($ShowHostStorageInfoProd){

Write-CustomOut "..Checking Hosts Storage Information"

$ShowHostStorage = @()

foreach ($cluster in (Get-View -ViewType ClusterComputeResource)) {

$vmhostsview = $cluster.host | % { Get-View $_ }

$vmhostview = $vmhostsview | Select -first 1

$ScsiLuns = $vmhostsview | % { $_.Config.StorageDevice.ScsiLun } | Select -unique *

$UUIDs = $ScsiLuns | Select -unique UUID

$Datastores = $vmhostsview | % { $_.Config.FileSystemVolume.MountInfo } | % { $_.Volume } | Select -Unique *

$HostLUN = $vmhostsview | % { $_.Config.StorageDevice.ScsiTopology.Adapter } | % { $_.Target | % { $_.LUN } } | select -unique *

foreach ($UUID in $UUIDs) {

$Lun = $ScsiLuns | ? { $_.UUID -eq $UUID.UUID } | Select -first 1

$objVolume = "" | Select Cluster, VolumeName, HostLUN, CanonicalName, DisplayName, VolumeType, CapacityGB, BlockSizeMb, VMFSVersion, LunType, Vendor, Model, Revision, ScsiLevel, UUID

$objVolume.Cluster = $cluster.Name

$objVolume.CanonicalName = $Lun.CanonicalName

$objVolume.HostLUN = ($HostLUN | ? { $_.ScsiLun -eq $Lun.Key } | select -unique LUN).LUN

$objVolume.UUID = $Lun.Uuid

$objVolume.CapacityGB = $Lun.Capacity.Block * $Lun.Capacity.BlockSize / 1GB

$objVolume.DisplayName = $Lun.DisplayName

$objVolume.LunType = $Lun.LunType

$objVolume.Vendor = $Lun.Vendor

$objVolume.Model = $Lun.Model

$objVolume.Revision = $Lun.Revision

$objVolume.ScsiLevel = $Lun.ScsiLevel

foreach ($vol in $Datastores) {

if ($vol.extent | % { $_.diskname -eq $Lun.CanonicalName}) {

$objVolume.VolumeName = $vol.Name

$objVolume.BlockSizeMb = $vol.BlockSizeMb

$objVolume.VMFSVersion = $vol.Version

$objVolume.VolumeType = "vmfs"

}

}

$ShowHostStorage += $objVolume

}

If (($ShowHostStorage | Measure-Object).count -ge 0) {

$MyReport += Get-CustomHeader "Production Host Storage Detailed Information" "The following provides a detailed list of the Hosts and LUNs presented to the Hosts in a Cluster"

$MyReport += Get-HTMLTable $ShowHostStorage

$MyReport += Get-CustomHeaderClose

}

}

}

Reply
0 Kudos