Pages

Tuesday, May 22, 2018

Convert a Dell Service Tag to Dell Express Service Tag using PowerShell

Convert a Dell Service Tag to Dell Express Service Tag using Powershell

Sometimes we need to talk with Dell to consult for an issue that we are dealing with for any Dell hardware and we are needed to provide the hardware's Express Service Tag or Service Tag, We can easily obtain a Server's service tag from the server by internal commands like WMIC (In case of Windows) or dmidecode in case of Linux but finding out the Express Service Tag becomes difficult sometimes as you have to either logon to the iDRAC or Open Manage server Administrator to obtain it or convert it from Dell's Support site.

I have written a simple script which can translate a Dell Service Taginto Express Service Tag.

This script can also be downloaded from Microsoft Technet Gallery
https://gallery.technet.microsoft.com/scriptcenter/Convert-a-Dell-Service-tag-3754c3ea?redir=0
 

## This Script has been written for converting a Dell Service Tag into Express service Tag
## Author : Prakash Kumar (prakash82x@gmail.com) May 22th 2018
## www.adminthing.blogspot.com
## Please use this script at your own risk.
##
## Usage:
## Since this has a function so it needs to be loaded into the memory of PS console by dot sourcing it: **
## PS C:\> . ./ConvertTo-ExpressServiceTag.ps1
## PS C:\> Convertto-ExpressServiceTag A1B2C3D

Function ConvertTo-ExpressServiceTag{
param(
    [Parameter(
    Mandatory=$True,
    Position=0,
    ValueFromPipeline=$True,
    ValueFromPipelineByPropertyName=$True ,
    HelpMessage="A Dell Service Tag as input is needed !!")][System.String]$ValB36 )
  
    Begin{}
  
        Process{
        $Range = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
        $ca = $ValB36.ToUpper().ToCharArray()
        [System.Array]::Reverse($ca)
        [System.Int64]$ValB10=0
   
        $i=0
        foreach($c in $ca){
            $ValB10 += $Range.IndexOf($c) * [System.Int64][System.Math]::Pow(36,$i)
            $i+=1
        }

        Write-Host -ForegroundColor Yellow "`nService Tag `t `t `t : `t $ValB36 `nExpress Service Tag `t :`t $ValB10"
    }

    End{}
   
}

Here is how to do this.