Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page
Converting Lun Serial to Serialhex - CMODE using Powershell
2023-11-03
06:31 AM
1,419 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
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!
Solved! See The Solution
1 ACCEPTED SOLUTION
Drew_C has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the ConvertTo-HexString function in that linked article. It works just fine with the cluster mode serial. There are several ways to get Powershell to ignore special characters in data.
1 REPLY 1
Drew_C has accepted the solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Use the ConvertTo-HexString function in that linked article. It works just fine with the cluster mode serial. There are several ways to get Powershell to ignore special characters in data.
