I had a similar issue in my environment with LUNs that service SQL servers. My short-term solution was to create a function that accepts the lun path (which in my environment includes the name of the cluster to which it is assigned) and returns the drive letter and a description of the volume. Then, I extracted the hostname from the volume name. WIth the volume name and the drive letter, I could then use WMI to gather information about the LUN from the OS perspective. Eventually, I hope to update my script to gather information dynamically from the DSM CLI on each server, but that enhancement is still quite a ways in the future. Below is some sample code. I hope you find it useful. (The original code interfaced with MS-Excel to create a spreadsheet of data, but I have removed the Excel code for clarity. I may have created a few bugs along the way. Sorry.)
function Get-DriveInfo ([string] $lunPath) {
switch ($lunPath) {
"/vol/dbcluster1_systemdb/qtree1/dbcluster1_systemdb" { return ("R", "Cluster1 SQL System Databases") }
"/vol/cluster1_quorum/quorum" { return ("Q", "Cluster1 Witness Disk") }
default { return ("Unknown", "Unknown") }
}
}
function Get-Disks ([string] $hostname) {
return (get-wmiobject win32_logicaldisk -filter "drivetype=3" -computername $hostname -credential $windowsCredential | sort-object DeviceID)
}
function Get-DiskIndex ([System.Array] $diskList, [string] $letter) {
if ($diskList -ne $null) {
$index=0
foreach ($disk in $disks) {
if (($disk.DeviceID.ToLower()) -eq ($letter+":").tolower()) {
return $index
}
$index++
}
}
else {
return $null
}
}
foreach ($netappName in $listOfNetAppNames) {
$currentNetapp = Connect-NaController -name $netappName -credential $netappCredential
$listOfLuns = Get-NaLun -controller $currentNetapp | Sort-Object -Property "Path"
if ($listOfLuns -ne $null) {
foreach ($lun in $listOfLuns) {
$hostname = $lun.path.split("/_")[2]
$driveLetter = Get-DriveInfo ($lun.path))[0]
$disks = Get-Disks ($hostname)
if ($disks -ne $null) {
$diskIndex = Get-DiskIndex $disks ($driveLetter)
$diskSpaceAllocated = $disks[$diskindex].size #Drive Space Allocated
$diskSpaceAvailable = $disks[$diskindex].FreeSpace #Drive Space Available
}
}
}
}