Recently I have had the need to look up devices through Dell’s support site. I thought it would be a perfect example of a task I can do through scripting the Service Tag & Dell support lookup tool. In the following post I explain how to get the service tag, place that data in a variable, use dot notation to get the data from the variable we need and subsequently open the browser at the correct dell support page for your device.
First we use the Get-CimInstance and calling the win32_bios in the process.
Get-CimInstance Win32_Bios
What I want to do is put this into a variable $serialNumber and use dot notation to call the data (SerialNumber) we want in the next line.
SMBIOSBIOSVersion : 1.8.0 Manufacturer : Dell Inc. Name : 1.8.0 SerialNumber : DHOSQW8 Version : DELL - 1072009
This only gets us partially there though. We have the data, but every time we call the variable we get all of the variable and not just the data we need. We could take the long route and filter out the rest of the variable, or we can use dot notation. With dot notation you can access properties of an object by specifying the name of the object, in our case the $serialNumber variable, followed by a dot (period) followed by the property name, again in our case it is SerialNumber we want.
Let’s see the variable assignation and the true first line of our script.
$serialNumber = Get-CimInstance Win32_Bios
Afterwards we need to pipe the information out to filter out what we do not need. So we use a new variable to do this. This correctly assignes the Service Tag to the variable $serviceTag.
$serviceTag = $serialNumber | select -ExpandProperty serialnumber
Your output from this command should be just your serial number and no other data. Just as the above code block shows. I want to keep this to one line so I will make this line:
$serviceTag = $serialNumber = Get-CimInstance Win32_Bios| select -ExpandProperty serialnumber
It is important to note you can write your script however you like. I just want to stay to two lines. If you do not care and it makes it easier to read you can write it like this:
$serialNumber = Get-CimInstance Win32_Bios $serviceTag = $serialNumber | select -ExpandProperty serialnumber
Either way works. Choose what works best and makes sense to you.
Now onto the Dell Site Information. To explain, Dell’s support site URL looks like this:
https://www.dell.com/support/home/en-us/product-support/servicetag/REALLY LONG ALPHANUMERIC TIED TO YOUR SERVICE TAG/overview
What we are going to do is grab the BIOS serial number. In Dell’s case this is the service tag from the commands above and interject the service tag into the URL while opening the URL in a browser.
Start-Process
is defined by Microsoft as:
The Start-Process
cmdlet starts one or more processes on the local computer. By default, Start-Process
creates a new process that inherits all the environment variables that are defined in the current process. To specify the program that runs in the process, enter an executable file or script file, or a file that can be opened by using a program on the computer. If you specify a non-executable file, Start-Process
starts the program that is associated with the file, similar to the Invoke-Item
cmdlet. You can use the parameters of Start-Process
to specify options, such as loading a user profile, starting the process in a new window, or using alternate credentials.
Using this we are going to call Start-Process
and add the URL, and let the environment variables do the rest of the work.
start-process "https://www.dell.com/support/home/en-us/product-support/servicetag/$serviceTag/overview"
That is all there is to it. The full script is below.
$serviceTag = $serialNumber = Get-CimInstance Win32_Bios| select -ExpandProperty serialnumber start-process "https://www.dell.com/support/home/en-us/product-support/servicetag/$serviceTag/overview"
Comment if this helped or you have a better way to do anything I have done.
-iNet