{"id":1102,"date":"2012-11-02T10:00:44","date_gmt":"2012-11-02T14:00:44","guid":{"rendered":"http:\/\/enterpriseadmins.org\/blog\/?p=1102"},"modified":"2012-11-02T09:41:18","modified_gmt":"2012-11-02T13:41:18","slug":"naa-id-to-vmax-device-id-using-powershell","status":"publish","type":"post","link":"https:\/\/enterpriseadmins.org\/blog\/scripting\/naa-id-to-vmax-device-id-using-powershell\/","title":{"rendered":"NAA ID To VMAX Device ID &#8211; using powershell"},"content":{"rendered":"<p>A few months ago I noticed a link to this awesome article titled: <a href=\"http:\/\/vmwise.com\/2012\/06\/01\/naa-ids-and-breaking-them-apart\/\">NAA id\u2019s and breaking them apart<\/a>, which dissects the NAA identifiers that you see in the vSphere client when looking at storage devices.  Recently I was working with my storage admin &#8212; I was seeing a 2.81MB device on all of the hosts in a cluster that he had not specifically presented.  Unfortunately I had no good way to tell him exactly which device I was seeing.  I then remembered and found this article and was able to convert the NAA ID to the VMAX device ID using the key described in the article.  While converting this device ID by hand, I thought&#8230;wouldn&#8217;t it be nice if I could just paste in the NAA ID and automatically convert it to the device ID?  I threw together a quick powershell function that does just that:<\/p>\n<pre><code class=\"language-powershell\">\r\nFunction Convert-NaaIdToVmaxDeviceId ($naa) {\r\n  # http:\/\/vmwise.com\/2012\/06\/01\/naa-ids-and-breaking-them-apart\/\r\n  if ($naa.length -ne 36) { \"NAA value must be 36 characters\"; break }\r\n  $deviceString = $naa.ToCharArray()\r\n  $device = [char][Convert]::ToInt32(\"$($deviceString[26])$($deviceString[27])\", 16)\r\n  $device += [char][Convert]::ToInt32(\"$($deviceString[28])$($deviceString[29])\", 16)\r\n  $device += [char][Convert]::ToInt32(\"$($deviceString[30])$($deviceString[31])\", 16)\r\n  $device += [char][Convert]::ToInt32(\"$($deviceString[32])$($deviceString[33])\", 16)\r\n  $device += [char][Convert]::ToInt32(\"$($deviceString[34])$($deviceString[35])\", 16)\r\n  return $device\r\n}\r\n<\/code><\/pre>\n<p>The function expects just one parameter and can be used like this:<\/p>\n<pre>Convert-NaaIdToVmaxDeviceId \"naa.60000970000000000000533031363641\"<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A few months ago I noticed a link to this awesome article titled: NAA id\u2019s and breaking them apart, which dissects the NAA identifiers that you see in the vSphere client when looking at storage devices. Recently I was working &hellip; <a href=\"https:\/\/enterpriseadmins.org\/blog\/scripting\/naa-id-to-vmax-device-id-using-powershell\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":6,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3,4],"tags":[],"class_list":["post-1102","post","type-post","status-publish","format-standard","hentry","category-scripting","category-virtualization"],"_links":{"self":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/comments?post=1102"}],"version-history":[{"count":5,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1102\/revisions"}],"predecessor-version":[{"id":1108,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/posts\/1102\/revisions\/1108"}],"wp:attachment":[{"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/media?parent=1102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/categories?post=1102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/enterpriseadmins.org\/blog\/wp-json\/wp\/v2\/tags?post=1102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}