Posted in
Virtual Machine Manager,
Windows Powershell |
4 Comments | 3,251 views | 22/05/2014 15:03
This is very basic function to get physical disk information of cluster shared volumes.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
| function Get-CSVDiskLun
{
param ($CSVName, $ClusterName=".")
if ($CSVName -like "CSVolume*")
{
$CSVVolume = Get-ClusterSharedVolume -Cluster $ClusterName | Where Name -eq $CSVName
}
else
{
$CSVVolume = Get-ClusterSharedVolume -Cluster $ClusterName | Where {$_.SharedVolumeInfo.FriendlyVolumeName -like "*\$CSVName"}
}
# Get CSV Volume Name
$CSVVolumeName = $CSVVolume.Name
# Get CSV Signature
$CSVSignature = ($CSVVolume | Get-ClusterParameter DiskSignature).Value.Substring(2)
# Get CSV Physical Disk
$PhysicalDisk = Get-WmiObject Win32_DiskDrive -ComputerName $ClusterName | Where {"{0:x}" -f $_.Signature -eq $CSVSignature}
# Get CSV Physical Disk DeviceID
$CSVDeviceID = $PhysicalDisk.DeviceID.Substring(4)
# Get CSV Physical Disk Bus
$CSVBus = $PhysicalDisk.SCSIBus
# Get CSV Physical Disk LunID
$CSVLunID = $PhysicalDisk.SCSILogicalUnit
# Get CSV Physical Disk Caption
$CSVCaption = $PhysicalDisk.Caption
# Output
$Value = $CSVVolumeName + ";" + $CSVDeviceID + ";" + $CSVLunID + ";" + $CSVCaption
Write-Host $Value
} |
function Get-CSVDiskLun
{
param ($CSVName, $ClusterName=".")
if ($CSVName -like "CSVolume*")
{
$CSVVolume = Get-ClusterSharedVolume -Cluster $ClusterName | Where Name -eq $CSVName
}
else
{
$CSVVolume = Get-ClusterSharedVolume -Cluster $ClusterName | Where {$_.SharedVolumeInfo.FriendlyVolumeName -like "*\$CSVName"}
}
# Get CSV Volume Name
$CSVVolumeName = $CSVVolume.Name
# Get CSV Signature
$CSVSignature = ($CSVVolume | Get-ClusterParameter DiskSignature).Value.Substring(2)
# Get CSV Physical Disk
$PhysicalDisk = Get-WmiObject Win32_DiskDrive -ComputerName $ClusterName | Where {"{0:x}" -f $_.Signature -eq $CSVSignature}
# Get CSV Physical Disk DeviceID
$CSVDeviceID = $PhysicalDisk.DeviceID.Substring(4)
# Get CSV Physical Disk Bus
$CSVBus = $PhysicalDisk.SCSIBus
# Get CSV Physical Disk LunID
$CSVLunID = $PhysicalDisk.SCSILogicalUnit
# Get CSV Physical Disk Caption
$CSVCaption = $PhysicalDisk.Caption
# Output
$Value = $CSVVolumeName + ";" + $CSVDeviceID + ";" + $CSVLunID + ";" + $CSVCaption
Write-Host $Value
}
You can call it like Get-CSVDiskLun Volume2 or Get-CSVDiskLun Volume2 Cluster01.