search
Categories
Sponsors
VirtualMetric Hyper-V Monitoring, Hyper-V Reporting
Archive
Blogroll

Badges
MCSE
Community

Cozumpark Bilisim Portali
Get-EMCDiskNumber – PowerShell Powermt Parser
Posted in Windows Powershell, Windows Server | 1 Comment | 5,897 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
	}
}

If you know Disk ID, you can use it:

Usage:

Get-EMCDiskNumber -DiskID "11E40"

Also you can display all disk names and ids:

Usage:

Get-EMCDiskNumber

That will output disk informations.


Comments (1)

Durga Prasad

February 20th, 2020
17:24:21

Hi, I am trying to automate disk mounting, for this I need DiskNumber, DiskName ( instead of Lagical ID) , can you please help in this ?

Example:
Logical device ID=45f4sd5g4d6f54g [Lun 1 ]

I am excepecting
DiskNumber DiskID
———- ——
3 Lun 1



Leave a Reply