Get-DellTags: Get Dell Tags and Express Service Code remotely

Get DELL Tag and Express Service Code remotely for more than one computer.

You can also commit different credentials for a specific domain. The below function Get-DellTags retrieves serials remotely from your machines. With the help of the function ConvertSerial the serial gets converted into a DELL Express Service Code on the fly.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
Function Get-DellTags
{
<#
.SYNOPSIS
    Retrieves the serial on a local or remote computer using Invoke-Command and converts into a DELL Express Service Code.

.DESCRIPTION
    Gets the PowerShell version on a local or remote computer using Invoke-Command.

.PARAMETER ComputerName
    A single Computer or an array of computer names. The default is localhost ($env:COMPUTERNAME).

.PARAMETER Credentials
    Commit PSCredential object or using Get-Credentials.

.PARAMETER Verbose
    Run in Verbose Mode.

.EXAMPLE
    PS C:> Get-DellTags -ComputerName Server01

    ComputerName    DellTag ExpressServiceCode URL
    ------------    ------- ------------------ ---
    Server01        FV9SAX4        34542623560 https://www.dell.com/support/home/us/en/19/product-support/servicetag/FV9SAX4/Research

.EXAMPLE
	PS C:> Get-DellTags -ComputerName Server01,Server02 -Credentials Get-Credentials

.EXAMPLE
    PS C:> Get-DellTags -ComputerName (Get-Content C:ServerList.txt)

.LINK

Home


.NOTES
    Author:  Sebastian Gräf
    Email:   sebastian@graef.io
    Date:    September 9, 2017
    PSVer:   2.0/3.0/4.0/5.0
#>

	[Cmdletbinding()]
	Param (
		[Parameter(
				   Mandatory = $false,
				   ValueFromPipeline = $true,
				   ValueFromPipelineByPropertyName = $true)]
		[string[]]$ComputerName = $Env:COMPUTERNAME,
		[Parameter(
				   ValueFromPipelineByPropertyName = $true,
				   Mandatory = $false,
				   ValueFromPipeline = $true)]
		[Alias(
			   'PSCredential'
			   )]
		[ValidateNotNull()]
		[System.Management.Automation.PSCredential]
		[System.Management.Automation.Credential()]
		$Credentials = [System.Management.Automation.PSCredential]::Empty
	)

	Begin
	{
		Write-Verbose " [$($MyInvocation.InvocationName)] :: Start Process"
        $ProgressCounter = 0
	}

	Process
	{
		foreach ($Computer in $ComputerName)
		{
            $ProgressCounter++
			Write-Progress -activity "Running on $Computer" -status "Please wait ..." -PercentComplete (($ProgressCounter / $ComputerName.length) * 100)
			if (Test-Connection $Computer)
			{
				Write-Verbose " [$($MyInvocation.InvocationName)] :: Processing $Computer"
				try
				{
					## If you want to use WMI
                    #$DellServiceTag = Get-WmiObject Win32_Bios -Credential $Credentials -ComputerName $Computer

                    ## If you want to use CIM
                    #$DellServiceTag = Get-CimInstance Win32_Bios -Credential $Credentials -ComputerName $Computer

                    $DellServiceTag = Invoke-Command -Computername $Computer -Scriptblock { Get-CimInstance Win32_Bios } -Credential $Credentials
					ConvertDellSerial $DellServiceTag.serialnumber
					$DellTags = @()
					$WMIObject = New-Object PSObject
					$WMIObject | add-member Noteproperty ComputerName $Computer -Force
					$WMIObject | add-member Noteproperty DellTag $DellServiceTag.serialnumber -Force
					$WMIObject | add-member Noteproperty ExpressServiceCode $Serial -Force
					$WMIObject | add-member Noteproperty URL "https://www.dell.com/support/home/us/en/19/product-support/servicetag/$($DellServiceTag.serialnumber)/Research" -Force
					$DellTags += $WMIObject
					$DellTags
				}
				catch
				{
					Write-Verbose " Host [$Computer] Failed with Error: $($Error[0])"
				}
			}
			else
			{
				Write-Verbose " Host [$Computer] Failed Connectivity Test "
			}
		}
	}
	End
	{
		Write-Verbose " [$($MyInvocation.InvocationName)] :: End Process"
	}
}
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
Function ConvertSerial
{
<#
.SYNOPSIS
    Converts DELL Tag Serial into a DELL Express Service Code.

.DESCRIPTION
    Converts DELL Tag Serial into a DELL Express Service Code.

.PARAMETER Serial
    Commit serial string.

.LINK

Home


.NOTES
    Author:  Sebastian Gräf
    Email:   ps@graef.io
    Date:    September 9, 2017
    PSVer:   2.0/3.0/4.0/5.0
#>
	param ($Serial)
	$36Base = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	$SerialLength = $Serial.length
	$Script:DellServiceCode = 0
	for ($x = 0; $x -lt $SerialLength; $x++)
	{
		for ($y = 0; $y -lt 36; $y++)
		{
			if ($Serial.substring($x, 1) -eq $36Base.substring($y, 1))
			{
				$answer = (($y) * ([math]::pow(36, $SerialLength - $x - 1)))
				$Script:DellServiceCode += $answer
			}
		}
	}
}