Dell Service Tags to Express Service Codes with Powershell

Knowing the Express Service Code greatly speeds up your Dell support experience. Unfortunately they can't be read from WMI like Service Tags. You can use a tool to convert the tags / codes on Dell's website, but that is not always convenient and for Enterprise customers often not feasible (f. ex. because you need to convert 1000+ Tags).

I couldn't find a Powershell converter for this task on the internet, but lots of VB and JS variants. So I went ahead and made one.


function convertfrom-base36 {

[CmdletBinding()]
param ([parameter(valuefrompipeline=$true, HelpMessage="Alphadecimal string to convert")][string]$ToConvert="")
$CharList = "0123456789abcdefghijklmnopqrstuvwxyz"
$inputarray = $ToConvert.tolower().tochararray()
[array]::reverse($inputarray)

[long]$result=0
$pos=0

foreach ($c in $inputarray) {
$result += $CharList.IndexOf($c) * [long][Math]::Pow(36, $pos)
$pos++
}
$result

<#
.SYNOPSIS
Converts an alphadecimal (base36) string to a decimal (base10) number.

.DESCRIPTION
Primarily made to convert Dell Service Tags to Dell Express Service Codes,
this function will convert alphadecimal strings to int64.

Not much (nothing) has been done to validate inputs or catch overflows.

V 1.0 Mirko Schnellbach 10 June 2011

.PARAMETER ToConvert
The alphadecimal string to convert.

.INPUTS
String. The alphadecimal string to convert.

.OUTPUTS
int64. Base10 representation of input.

.LINK
http://support.dell.com/support/topics/global.aspx/support/my_systems_info/express_service_code?c=us&l=en&s=gen

.EXAMPLE
"BQHW92J" | convertfrom-base36

25546784491

.EXAMPLE
convertfrom-base36 "BQHW92J"

25546784491

#>
}

Thanks and credit

To Michael Stum for his C# version!