0

I need to learn serial number of a computer. How can I do this with PowerShell. I was using wmic bios get serialnumber but its deprecated and removed on windows 11.

1
  • Note that the degree to which any method to get the SN works is affected by the information provided by the manufacturer which may vary from product to product. trusting OEMs to fill out fields can be hit-or-miss. Commented Aug 27 at 16:27

3 Answers 3

4

The PowerShell equivalent to wmic.exe is Get-CimInstance; you can also use its alias gcim (in the PS console; aliases shouldn't be used in scripts).
Working with Get-CimInstance requires the WMI class name, though, while your command uses one of the aliases that wmic.exe offers. To find the class that an alias actually uses, you can use wmic.exe alias list brief, and then filter that for the alias:

wmic.exe alias list brief | Select-String BIOS -SimpleMatch 

This will show the actual query as Select * from Win32_BIOS.

So the full PowerShell command (to be used in a script) would be:

Get-CimInstance -ClassName Win32_BIOS 

For a quick query in the console, use the alias and omit the named parameter:

gcim Win32_BIOS 

Either of which could be piped to Select-Object -ExpandProperty SerialNumber or its shorter version select -expa serial*. But since the default output only shows 5 properties anyway, that might not even be required for you.

But Get-ComputerInfo for a simple WMI query is overkill; that gets a lot of other information that you're throwing away again.

1
  • Thanks gcim Win32_BIOS is easy to remember and type. Commented Aug 28 at 8:30
3

I use get-computerinfo | select biosseralnumber.

Or just get-computerinfo and scroll down a little, if I am not scripting. Its a lot easier to type and memorize.

1
  • 1
    (get-computerinfo).biosseralnumber also works. Commented Aug 27 at 7:38
2

This will return the motherboard (PCB) S/N:

Get-CimInstance Win32_BaseBoard | Select SerialNumber 

Or using the compact syntax:

(Get-CimInstance Win32_BaseBoard).SerialNumber 
2
  • This gives me a different SN than the other two answers, but if I replace Win32_Baseboard with Win32_BIOS both yield the expected value. Commented Sep 2 at 21:39
  • 1
    @Dallas Win32_BaseBoard contains the serial number of the motherboard (as asked in the question), and Win32_BIOS the BIOS serial number. One is tied to the hardware, the other to the firmware. I don't expect them to be the same. Commented Sep 3 at 5:40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.