Posted in
Windows Powershell,
Windows Server |
1 Comment | 5,894 views | 13/03/2014 11:57
You can use following function to get EMC Disk Numbers via PowerPath:
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
39
40
41
42
43
44
45
46
| function Get-EMCDiskNumber
{
param ($DiskID)
function Get-PowerMtOutput
{
# Get Powermt Output
$Outputs = powermt display dev=all
# Create Hash Table
$Properties = New-Object Psobject
foreach ($Output in $Outputs)
{
# Clear Variables
$DiskNumber = $Null;
$DiskID = $Null;
if ($Output -ne "")
{
if ($Output -match 'Pseudo name=harddisk(?<Name>\d+)') { $DiskNumber = $Matches["Name"] }
if ($Output -match 'Logical device ID=(?<ID>\w+)') { $DiskID = $Matches["ID"] }
if ($DiskID) { $Properties | Add-Member Noteproperty DiskID $DiskID }
if ($DiskNumber) { $Properties | Add-Member Noteproperty DiskNumber $DiskNumber }
}
else
{
# Output Data
Write-Output $Properties
# Create New Hash Table
$Properties = New-Object Psobject
}
}
}
if ($DiskID)
{
Get-PowerMtOutput | Where { $_.DiskID -eq $DiskID }
}
else
{
Get-PowerMtOutput
}
} |
function Get-EMCDiskNumber
{
param ($DiskID)
function Get-PowerMtOutput
{
# Get Powermt Output
$Outputs = powermt display dev=all
# Create Hash Table
$Properties = New-Object Psobject
foreach ($Output in $Outputs)
{
# Clear Variables
$DiskNumber = $Null;
$DiskID = $Null;
if ($Output -ne "")
{
if ($Output -match 'Pseudo name=harddisk(?<Name>\d+)') { $DiskNumber = $Matches["Name"] }
if ($Output -match 'Logical device ID=(?<ID>\w+)') { $DiskID = $Matches["ID"] }
if ($DiskID) { $Properties | Add-Member Noteproperty DiskID $DiskID }
if ($DiskNumber) { $Properties | Add-Member Noteproperty DiskNumber $DiskNumber }
}
else
{
# Output Data
Write-Output $Properties
# Create New Hash Table
$Properties = New-Object Psobject
}
}
}
if ($DiskID)
{
Get-PowerMtOutput | Where { $_.DiskID -eq $DiskID }
}
else
{
Get-PowerMtOutput
}
}
If you know Disk ID, you can use it:
Usage:
Get-EMCDiskNumber -DiskID "11E40" |
Get-EMCDiskNumber -DiskID "11E40"
Also you can display all disk names and ids:
Usage:
That will output disk informations.