익명 07:47

Powershell get motherboard serial number

Powershell get motherboard serial number

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.



Top Answer/Comment:

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.

상단 광고의 [X] 버튼을 누르면 내용이 보입니다