<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Any way to get lun serial number in hex through powershell? in Microsoft Virtualization Discussions</title>
    <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28657#M1311</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh perfect! Thanks much Eric!&lt;/P&gt;&lt;P&gt;I had just figured out the route with invoke-nassh but like you said, then I can't use RPC and integrated auth so I was going down the road of prompting for credentials.&lt;/P&gt;&lt;P&gt;This is much better! Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Jul 2012 18:28:40 GMT</pubDate>
    <dc:creator>MACKOPES1</dc:creator>
    <dc:date>2012-07-13T18:28:40Z</dc:date>
    <item>
      <title>Any way to get lun serial number in hex through powershell?</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28647#M1309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Get-NaLunSerialNumber doesn't seem to have a way to return the hex value for the lun serial number like 'lun serial -x' does from the command line.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Does anyone know of another 'api' way to get this? I'm trying to use it to cross reference luns with the naa id on a VMware environment (which matches the hex serial number perfectly)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Aaron&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jun 2025 06:22:49 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28647#M1309</guid>
      <dc:creator>MACKOPES1</dc:creator>
      <dc:date>2025-06-05T06:22:49Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get lun serial number in hex through powershell?</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28650#M1310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are a few ways to do it.&amp;nbsp; First, you could just parse the output of the "lun serial -x" command with a regex like this:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; (Invoke-NaSsh "lun serial -x /vol/testluns/lun1" ) -replace ".*(0x\w*).*", "`$1"&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;0x50344461685a634562587732&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But not everybody is nuts about regexes, and the Invoke-NaSsh cmdlet doesn't work if you are using RPC.&amp;nbsp; So the second method makes use of the fact that the "-x" hex representation is just the characters converted to ASCII hex.&amp;nbsp; You &lt;EM&gt;can &lt;/EM&gt;do the whole conversion in one line:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; ((Get-NaLunSerialNumber /vol/testluns/lun1).ToCharArray() | % {([byte][char]$_).ToString("X2")}) -join ""&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;50344461685A634562587732&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But that's a little unwieldy, especially if you want to reuse it later.&amp;nbsp; So, I'd probably define a function that does that for you:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;function ConvertTo-HexString([string]$input)&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;{&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [byte[]]$bytes = $input.ToCharArray() &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $hexBytes = $bytes | % {$_.ToString("X2")}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $hexBytes -join ""&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;}&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;PS C:\&amp;gt; Get-NaLunSerialNumber /vol/testluns/lun1 | ConvertTo-HexString&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;50344461685A634562587732&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then you can put that function in the top of your script.&amp;nbsp; Or if it's something you want to use from the commandline everyday, you can put it in your PS profile (the path is in the $profile variable) and then restart PowerShell.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 12:54:49 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28650#M1310</guid>
      <dc:creator>timothyn</dc:creator>
      <dc:date>2012-07-13T12:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get lun serial number in hex through powershell?</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28657#M1311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh perfect! Thanks much Eric!&lt;/P&gt;&lt;P&gt;I had just figured out the route with invoke-nassh but like you said, then I can't use RPC and integrated auth so I was going down the road of prompting for credentials.&lt;/P&gt;&lt;P&gt;This is much better! Thanks again!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;AK&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 18:28:40 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28657#M1311</guid>
      <dc:creator>MACKOPES1</dc:creator>
      <dc:date>2012-07-13T18:28:40Z</dc:date>
    </item>
    <item>
      <title>Re: Any way to get lun serial number in hex through powershell?</title>
      <link>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28661#M1312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;FYI, I tweaked it a bit more to put it in a single function:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;###############################################################################################&lt;/P&gt;&lt;P&gt;## Get-NALunSerialNumberHex: Function that gathers the Hex Serial number of an NALun&lt;/P&gt;&lt;P&gt;###############################################################################################&lt;/P&gt;&lt;P&gt;Function Get-NALunSerialNumberHex {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; param (&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [parameter(Mandatory=$true)]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $LunPath&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Write-Host "[Gathering Lun Serial Number]" -ForegroundColor Cyan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; $LunSerial = ((Get-NaLunSerialNumber $LunPath).ToCharArray() | % {([byte][char]$_).ToString("X2")}) -join ""&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; return $LunSerial&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Jul 2012 19:09:01 GMT</pubDate>
      <guid>https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28661#M1312</guid>
      <dc:creator>MACKOPES1</dc:creator>
      <dc:date>2012-07-13T19:09:01Z</dc:date>
    </item>
  </channel>
</rss>

