Powershell: Convert VMware NAA value to Frame and Device ID (for vMax and Symmetrix)
Summary:
Found a script to convert the naa value to device id, but not return the frame info. So I augmented it to parse that info out as well.
Script Module:
Function Convert-NaaIdToVmaxFrameAndDeviceId ($naa) {
Found a script to convert the naa value to device id, but not return the frame info. So I augmented it to parse that info out as well.
Script Module:
Function Convert-NaaIdToVmaxFrameAndDeviceId ($naa) {
# Original -> http://vmwise.com/2012/06/01/naa-ids-and-breaking-them-apart/ if ($naa.length -ne 36) { "NAA value must be 36 characters"; break } $deviceString = $naa.ToCharArray() # Prepended w/ Frame info. $device = ("Frame $($deviceString[20])$($deviceString[21])$($deviceString[22])$($deviceString[23]) Device ") $device += [char][Convert]::ToInt32("$($deviceString[26])$($deviceString[27])", 16) $device += [char][Convert]::ToInt32("$($deviceString[28])$($deviceString[29])", 16) $device += [char][Convert]::ToInt32("$($deviceString[30])$($deviceString[31])", 16) $device += [char][Convert]::ToInt32("$($deviceString[32])$($deviceString[33])", 16) $device += [char][Convert]::ToInt32("$($deviceString[34])$($deviceString[35])", 16) return $device }
To use it:
- Save the above into a .psm1 file.
- Import-Module nameofpsm1file.psm1
- Convert-NaaIdToVMaxFrameAndDeviceID naa.#############################
- This will return something like this: Frame #### Device ######
To use it programmatically:
- Import the module
- $LUNs = Get-VMHost | Get-ScsiLUN | where {$_.Model -match "SYMMETRIX"};
- Foreach ($LUN in $LUNs){Convert-NaaIdToVMaxFrameAndDeviceID $_.CanonicalName}
- This will return all vMax/Symmetrix LUNs attached to all hosts in your vCenter server translating the naa value to "Frame #### Device ######" format.
Stay tuned for my next module where I translate vml RDM entries into Frame and Device ID's.
Comments