Hi
I am trying to find a way to convert a LUN SerialNumber to a Serial-hex using powershell - unfortunately this is not an option off the get-nclun applet.
I want to use a CSV column containing Lun Serials as my data source and replace the data with the serial-hex. I initially tried this
# Replace 'input.csv' and 'output.csv' with your file paths
$inputFile = 'input.csv'
$outputFile = 'output.csv'
# Read the CSV file
$data = Import-Csv $inputFile
# Convert the 'ColumnName' column from decimal to hexadecimal
$data = $data | ForEach-Object {
$_.ColumnName = [Convert]::ToString([int]$_.ColumnName, 16)
$_
}
# Export the updated data to a new CSV file
$data | Export-Csv -Path $outputFile -NoTypeInformation
However an error of this type is returned for each line - "Cannot convert value "83J6k$UbONg6" to type "System.Int32". Error: "Input string was not in a correct format."
I found this article
https://community.netapp.com/t5/Microsoft-Virtualization-Discussions/Any-way-to-get-lun-serial-number-in-hex-through-powershell/m-p/28647
However when the concept to CMODE I am getting back an 82 character string as opposed to the 24 character I would expect.
I have also tried format-hex and other functions but what mechanism I use I end up with an incorrect result. Additionally I seem to be encountering is the use of '$' in the Lun Serials which confuses powershell.
Help!