Get Motherboard Information Using Windows PowerShell

Publish Date: September 27, 2018

Get motherboard information using PowerShell

Ever wanted to detect the motherboard information like manufacturer, model, version for any Windows PC? You do not need to install any third-party software to do so. The Get-CimInstance PowerShell cmdlet can get this information for you by querying Common Information Model (CIM). Back in the days, Microsoft had their own implementation of CIM known as Windows Management Instrumentation (WMI) and Get-WmiObject cmdlet was used to query WMI for information. But starting with PowerShell 3.0, Get-WmiObject cmdlet has now been superseded by Get-CimInstance.

Get motherboard information

To get the information about motherboard, open Windows PowerShell and type the following command:

Get-CimInstance -Class Win32_BaseBoard | Format-Table Manufacturer, Product, SerialNumber, Version -Auto
Get motherboard information using PowerShell
Get motherboard information using PowerShell

The above command displays the Motherboard manufacturer, Model, Serial number and Revision number for local computer.

The good news is that Get-CimInstance supports ComputerName parameter where you can specify remote computer name and get the information about that. 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-CimInstance -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.

Get memory (RAM) information

The beauty of Get-CimInstance is that, not only motherboard, but you can query a whole lot of things from CIM. For example, to get the memory (RAM) information using PowerShell, you can use the following command:

Get-CimInstance Win32_PhysicalMemory | ft Manufacturer, Capacity, SerialNumber, BankLabel, ConfiguredClockSpeed, DeviceLocator -Auto
Get memory information using PowerShell
Get memory information using PowerShell

To get a more readable memory size and clock speed of memory, you might want to run the following command instead:

Get-CimInstance Win32_PhysicalMemory | Format-Table Manufacturer, SerialNumber, BankLabel, DeviceLocator, @{n="Size (GB)"; e={($_.Capacity/1GB)}; align="center"}, @{n="ClockSpeed (MHz)"; e={($_.ConfiguredClockSpeed)}; align="center"} -Auto

Get processor (CPU) information

To get the processor information, you could use the following command:

Get-CimInstance Win32_Processor
Get processor information using PowerShell
Get processor information using PowerShell

If the default information returned by this command isn’t enough, you could add -Property * parameter do display more detailed information.

Get operating system (OS) information

To get the operating system information, you could use the following command:

Get-CimInstance Win32_OperatingSystem | Select Caption, BuildNumber, Version, SystemDirectory
Get operating system information using PowerShell
Get operating system information using PowerShell

These are just a few examples of information you can get using Get-CimInstance cmdlet. There are whole lot of CIM classes that you can use to fetch the relevant and detailed  information. To learn about various CIM classes, visit this official page.

Creating Get-BoardInfo PowerShell module

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:

PowerShell Telnet Module Path
PowerShell Telnet Module Path

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

If you have already started loving PowerShell, you can directly create it by running the following PowerShell command:

ise $(New-Item $HOME\Documents\WindowsPowerShell\Modules\Get-BoardInfo\Get-BoardInfo.psm1 -Force)

This command will create a PowerShell module file and open it using PowerShell ISE at the same time.

Now, copy the following code, paste it into the PowerShell ISE, and press “Ctrl+S” to 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 domain\user

    )
    $BoardInfo = New-Object System.Collections.Arraylist
    foreach($Computer in $ComputerName) {
        if (Test-Connection -ComputerName $Computer -Count 2 -Quiet) {
        $BoardInfo.add($(Get-CimInstance -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 current PowerShell console and open a new one. 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.

Getting the help for Get-BoardInfo module
Getting the help for Get-BoardInfo module

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:

Getting the help examples for Get-BoardInfo module
Getting the help examples for Get-BoardInfo module

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. In the same way, you could create another module for getting memory information using PowerShell and so on.

That was it for this tutorial. If you find this tutorial helpful, please leave a comment below and feel free to share it with others.



Microsoft Certified | Cisco Certified

Leave a Reply