Get Motherboard Information Using Windows PowerShell

Ever wanted to detect the motherboard information like Manufacturer, model, version etc. for any Windows PC? You do not need to install any third-party software to do so. The Get-WMIObject PowerShell cmdlet can get this information for you by querying Windows Management Instrumentation (WMI).

The good news is that Get-WMIObject supports ComputerName parameter where you can specify remote computer name and get the information about that.

Open Windows PowerShell and type the following command:

PS D:\MyScripts> Get-WmiObject -Class Win32_BaseBoard | Format-Table Manufacturer, Product, SerialNumber, Version

Manufacturer Product SerialNumber Version
------------ ------- ------------ -------
ASUSTeK COMPUTER INC. H110M-CS 160882578900655 Rev X.0x

The above command displays the Motherboard manufacturer, Model, Serial number and Revision number for local computer. If you want to get the information about any remote server, just add ComputerName parameter and specify the name of computer/server as shown below:

Get-WmiObject -Class Win32_BaseBoard -ComputerName DC1 | Format-Table Manufacturer, Product, SerialNumber, Version

If you are a system admin and often need this information about any server or computer, you can continue reading and I’ll show you how to create a cmdlet that will work exactly like other Windows PowerShell cmdlets work.

Creating Get-BoardInfo PowerShell Cmdlet

For this command to behave and work as native PowerShell cmdlet, you need to create a directory structure and then create a file with the same name as shown in following screenshot:

PowrerShell Module Path

In you computer, Go to your documents directory, then create a directory named WindowsPowerShell\Modules\Get-BoardInfo directories.  Inside Get-BoardInfo directory, create a file named Get-BoardInfo.psm1.

If you already started loving PowerShell, you can create it via PowerShell command:

New-Item -ItemType File -Path "C:\users\$env:UserName\documents\WindowsPowerShell\Modules\Get-BoardInfo\Get-BoardInfo.psm1" -Force

Remember to change C: to your OS drive. This command will create the folders and file for you.

Now open up this file using text editor of your choice or with PowerShell ISE if you know about it. I prefer to use PowerShell ISE, so I will run the following command in PowerShell console:

ise "C:\users\$env:UserName\documents\WindowsPowerShell\Modules\Get-BoardInfo\Get-BoardInfo.psm1"

Now, copy and paste the following code into the file you created and save it.

<#
.Synopsis
Gets the basic information about motherboard

.Description
The Get-BoardInfo Cmdlet displays the basic system information like Motherboard manufacturer, Model, Serial Number, Revision. The output can be formatted using format Cmdlets available in Windows PowerShell like Format-Table, Format-List.

.Parameter <ComputerName>
This is a required parameter where you need to specify one or more computer name(s)

.Example
Get-BoardInfo -ComputerName DC1, DC2 -Credential domain\admin | Format-Table -AutoSize
This command retrieves the Motherboard information about DC1 and DC2 using alternate credentials and displays the information in Table format

.Example
Get-BoardInfo -ComputerName $(Get-Content "C:\Computers.txt") | Format-Table -AutoSize
This command takes the list of Computer names from a text file and pipe each computer to Get-BoardInfo Cmdlet to retrieve the Motherboard information of all the computers

.Example
Get-BoardInfo -ComputerName $(Get-Content "C:\Computers.txt") | Export-Csv C:\BoardInfo.csv
This command takes the list of Computer names from a text file and pipe each computer to Get-BoardInfo Cmdlet to retrieve the Motherboard information of all the computers and creates a CSV report
#>
Function Get-BoardInfo{

[CmdletBinding()]
param(
[Parameter(Mandatory=$true,
ValueFromPipeline=$true,
ValueFromPipelineByPropertyName=$true)]
[Alias ('HostName','cn','Host','Computer')]
[String[]]$ComputerName='localhost',
[String]$Namespace = 'root\CIMV2',
[System.Management.Automation.CredentialAttribute()] 
$Credential = 'Get-Credential'
)
$BoardInfo = New-Object System.Collections.Arraylist
foreach($Computer in $ComputerName) {
if (Test-Connection -ComputerName $Computer -Count 2 -Quiet) {
$BoardInfo.add($(Get-WmiObject -Class Win32_BaseBoard -ComputerName $Computer -Namespace $Namespace -Credential $Credential)) | Out-Null
} 

else {
Write-Host "Could not connect to $Computer" -ForegroundColor Red
} 
}
Write-Output $BoardInfo | Select @{Label="ComputerName";Expression="PSComputerName"},@{Label="Board Manufacturer";Expression="Manufacturer"},@{Label="Board Model";Expression="Product"},@{Label="Board SerialNumber";Expression="SerialNumber"},@{Label="Board Revision";Expression="Version"} 

}

If you have done everything correctly so far, you will be able to find your Get-BoardInfo cmdlet ready.

Just close your Windows PowerShell console and open a new console again. Now, type the following command:

Get-Help Get-BoardInfo

If you see the output as shown in following image, you have created a PowerShell module properly and it will work just like other PowerShell cmdlets.

Get-Help Get-BoardInfo

If you are familiar with PowerShell cmdlets, you will understand that you can use PowerShell’s built-in Get-Help cmdlet to know how our Get-BoardInfo cmdlet works. To see the examples on how you can use this, type the following command:

Get-Help Get-BoardInfo -Examples

You should see the examples as shown in following screenshot:

Get-Help Get-BoardInfo -Examples

To get the information about multiple PCs like NODE01, NODE02, and NODE03, use the cmdlet as shown below

Get-BoardInfo -ComputerName NODE01, NODE02, NODE03 | Format-Table -Auto

You can also use this cmdlet to get a list of computers stored in a text file and fetch the motherboard information about all those computers and even export that information into a CSV file.

Get-BoardInfo -ComputerName $(Get-Content "C:\Computers.txt") | Export-Csv C:\BoardInfo.csv

Pretty cool! right?

Take some time to read the examples, and you will understand what you can achieve with the PowerShell module you just created. If you find this tutorial helpful, please leave a comment below and feel free to share it with others.



Microsoft Certified Professional | Cisco Certified Network Associate

Leave a Reply