Win32_systemenclosure Serial Number Rating: 3,4/5 811 votes
Learning has never been so easy!

Jun 29, 2017  I question naming a computer after the user who's logged in. What if you reprovision the machine to someone else? Now the script has got to rename it again? What if someone just borrows it? Naw, I say name the computer after the serial number and be done with it forever. That wouldn't be ideal for our use case here.

If you ever have to pull system Serial Number for warranties, you know it can be a pain, especially if you have to drive to a location to pull it. here is a quick way to get it from the bios using WMI Calls.

3 Steps total

Step 1: Open CMD

Hit Win+ R and type in CMD. Press Enter

Step 2: Run the command

Type in 'WMIC Bios get serialnumber'

Step 3: Get results

If you have a Dell you will see the service tag for the system. if you have an HP, you will see the SN of the system.

You can incorporate WMI calls into almost any script/powershell instance for easy automation. We use this same call to name our computers during MDT imaging.

34 Comments

  • Thai Pepper
    MarcusH45 Sep 19, 2018 at 09:52am

    Thanks for sharing. Good way to get the serial number when the sticker gets taken off.

  • Jalapeno
    nilstiebos Sep 19, 2018 at 09:58am

    Also, you can use the following commands to get the name and model of the computer:
    WMIC ComputerSystem Get name
    WMIC ComputerSystem Get model

  • Datil
    deanmoncaster Sep 19, 2018 at 10:47am

    That was bloody fantastic!!
    six more words to go, why do they have minimum words? it just means i have to waste my time writing rubbish that isn't relevant.

  • Poblano
    DouglasCH Sep 19, 2018 at 10:55am

    Would anyone out there have a good script that can pull the BIOS serial number, The computer hostname, and the hard drive SN all at the same time.

    I've used
    wmic path win32_physicalmedia get serialnumber for the hard drives
    wmic bios get serialnumber for the Dell service tag
    I know the host name i'm hitting but I would love the information on the same line with the Serial Numbers.

    One day Sumer wants to marry to that girl and at the spot shagun was there explaining sumer their relationship but sumer denies.Suddenly stones were falling and fire was lit up everywhere,that. Sahara One Sansaar. One Stop Destination For 'SAHARA ONE' Show Song's, Promo's & Best Scene's. Keep Visiting & Do Subscribe. Get YouTube TV Best of YouTube. Sahara one tv serial song. Shows -Kismat Connection, Woh Rehne Waali Mehlon Ki, Ghar. Ek Sapnaa, Doli Saja Ke, Mata Ki Chowki, Shubh Kadam. Please Visit & Like Our Fan Page. Please Like & follow our Fan Page - Kalyug Mein Bhakti Ki Shakti: Mata Ki Chowki - Popular Mythological Show Of Sahara One.

    I'm looking for something that could combine it all in say a tab delimited text file or excel table. Digimon world dusk ds cheat codes. I'm not the best at scripting and can't find how to combine them in one fancy query.

  • Jalapeno
    TimY Sep 19, 2018 at 11:02am

    What would be the command to pull a BIOS serial number from a remote system?

  • Serrano
    Shaundor Sep 19, 2018 at 11:28am

    ooo very handy! Thanks for sharing! I'll definitely put this to good use.

  • Poblano
    crorrigan Sep 19, 2018 at 12:37pm

    Amazing thank you, we just have Surface Pros at work now. The serial numbers are insanely tiny and hidden away and make my eyes bleed

  • Chipotle
    Elaine7755 Sep 19, 2018 at 12:44pm

    That's very cool, no more getting the magnifying glass out!!

  • Chipotle
    carlseabold Sep 19, 2018 at 12:53pm

    TimY - is say the easiest way would be to use psexec from sysinternals.

  • Tabasco
    Big Boss IT Sep 19, 2018 at 01:23pm

    There are a lot of helpful commands in wmic that can be used with WMIC. Monitor info, physical info on the memory in the board (see what is installed without opening up the case), ports, etc.

    run WMIC /? to see them

  • Thai Pepper
    Kristi1548 Sep 19, 2018 at 01:32pm

    Powershell also works great for this.

    get-wmiobject win32_computersystemproduct

    or for a remote machine
    get-wmiobject win32_computersystemproduct -computername computername

  • Chipotle
    Phil7965 Sep 19, 2018 at 01:38pm

    Thanks for sharing this! Very helpful and informative. Kudos to you.

  • Tabasco
    LanceHarmstrong Sep 19, 2018 at 01:40pm

    I've been using the following for Dell service tags:

    gwmi win32_bios

  • Jalapeno
    Xzorsh Sep 19, 2018 at 01:56pm

    I wrote a (very) simple PowerShell script, I've had expanded versions of it in the past (but they got lost - easy to recreate, though). It pulls information (name, OS, license, serial number, asset tag, etc. and saves it in a file %NAME%.txt as well as adds it to a text file which can be renamed to CSV and opened in Excel.

    You run it as an admin (too bad the screen is narrow, it's a lot easier to read when it's wide enough):

    $Computer_Name=(Get-WmiObject -Class Win32_ComputerSystem -Property Name).Name
    $SerNum=(Get-WmiObject win32_SystemEnclosure).serialnumber
    $Asset=(Get-WmiObject Win32_SystemEnclosure).SMBiosAssetTag
    $License=(Get-WmiObject -query 'select * from SoftwareLicensingService').OA3xOriginalProductKey
    $vendor=(Get-WmiObject win32_ComputerSystem).Manufacturer
    $model=(Get-WmiObject win32_ComputerSystem).Model
    $Windows_Ver=(Get-WmiObject win32_OperatingSystem).caption
    $bit=(Get-WmiObject win32_OperatingSystem).OSArchitecture
    ('Computer Name: ' + $Computer_Name) Out-File $($Computer_Name + '_report.txt')
    ('Asset Tag: ' + $Asset) Add-Content $($Computer_Name + '_report.txt')
    ('Serial Number: ' + $SerNum) Add-Content $($Computer_Name + '_report.txt')
    ('Windows Version: ' + $Windows_Ver + ' ' + $bit) Add-Content $($Computer_Name + '_report.txt')
    ('Windows License: ' + $License) Add-Content $($Computer_Name + '_report.txt')
    ('Vendor: ' + $vendor) Add-Content $($Computer_Name + '_report.txt')
    ('Model: ' + $model) Add-Content $($Computer_Name + '_report.txt')
    $Computer_Name + ',' + $Asset + ',' + $SerNum + ',' + $Windows_Ver + ',' + $License + ',' + $vendor + ',' + $model Add-Content list.txt

  • Cayenne
    jma89.tk Sep 19, 2018 at 02:03pm

    I use this one to get the BIOS version when checking to see if there's an update available from Dell:

    wmic bios get smbiosbiosversion

  • prev
  • 1
  • 2
  • 3
  • next
-->

WMI tasks for computer hardware obtain information about the presence, state, or properties of hardware components. For example, you can determine whether a computer is a desktop or laptop. For other examples, see the TechNet ScriptCenter at https://www.microsoft.com/technet.

The script examples shown in this topic obtain data only from the local computer. For more information about how to use the script to obtain data from remote computers, see Connecting to WMI on a Remote Computer.

To run a script

The following procedure describes how to run a script.

  1. Copy the code and save it in a file with a .vbs extension, such as filename.vbs. Ensure that your text editor does not add a .txt extension to the file.
  2. Open a command prompt window and navigate to the directory where you saved the file.
  3. Type cscript filename.vbs at the command prompt.
  4. If you cannot access an event log, check to see if you are running from an Elevated command prompt. Some Event Log, such as the Security Event Log, may be protected by User Access Controls (UAC).

Note

By default, cscript displays the output of a script in the command prompt window. Because WMI scripts can produce large amounts of output, you might want to redirect the output to a file. Type cscript filename.vbs > outfile.txt at the command prompt to redirect the output of the filename.vbs script to outfile.txt.

The following table lists script examples that can be used to obtain various types of data from the local computer.

How do I..WMI classes or methods
..determine how much free memory a computer has?Use the class Win32_OperatingSystem and the FreePhysicalMemory property.
VB
PowerShell
..determine whether a computer has a DVD drive?

Use the Win32_CDROMDrive class and check for the acronym DVD in the Name or DeviceID property.

..determine how much RAM is installed in a computer?

Use the Win32_ComputerSystem class and check the value of the TotalPhysicalMemory property.

VB
PowerShell
..determine if a computer has more than one processor?

Use the Win32_ComputerSystem class and the property NumberOfProcessors.

..determine whether a computer has a PCMCIA slot?

Use the Win32_PCMCIAController class and check the value of the Count property. If Count is 0, then the computer has no PCMCIA slots.

VB
PowerShell
..identify devices that are not working (those marked with an exclamation point icon in Device Manager)?

Use the Win32_PnPEntity class and use the following clause in your WQL query. WHERE ConfigManagerErrorCode <> 0 Note that this code may not detect USB devices that are missing drivers.

..determine the properties of the mouse used on computer?

Use the Win32_PointingDevice class. This returns the properties of all pointing devices, not just mouse devices.

VB
PowerShell
..determine the speed of a processor installed in a computer?

Use the Win32_Processor class and check the value of the MaxClockSpeed property.

..determine whether a computer is a tower, a mini-tower, a laptop, and so on?

Use the Win32_SystemEnclosure class and check the value of the ChassisType property.

VB
PowerShell
..get the serial number and asset tag of a computer?

Use the Win32_SystemEnclosure class, and the properties SerialNumber and SMBIOSAssetTag.

..determine what kind of device is plugged into a USB port?

Use the Win32_USBHub class and check the Description property. This property may have a value such as 'Mass Storage Device' or 'Printing Support'.

VB
PowerShell
..determine how many tape drives are installed on a computer?

Use the class Win32_TapeDrive class and then use the SWbemObjectSet.Count method. If Count = 0, then no tape drives are installed on the computer.

Examples

The following TechNet Gallery example code describes how to list the free space of all drives for several machines.

The Get-ComputerInfo - Query Computer Info From Local/Remote Computers - (WMI) PowerShell sample on TechNet Gallery uses a number of calls to hardware and software to display information about a local or remote system.

The Multithreaded System Asset Gathering with Powershell PowerShell sample on TechNetGallery gathers a plethora of useful system information via WMI and multithreading with powershell.

Related topics