⚡ PowerShell 5.1+

Get Keyboard Info Report

Queries Win32_Keyboard via WMI and reports Keyboard Info in a formatted table, with an optional CSV export.

By WindowsScripting.com · 912 B
Get-KeyboardReport.ps1
<#
.SYNOPSIS
    Reports Keyboard Info on this computer via WMI (Win32_Keyboard).

.DESCRIPTION
    Queries Win32_Keyboard and displays Description, Layout, NumberOfFunctionKeys for each item found.
    Use -ExportPath to also save the results to a CSV file.

.PARAMETER ExportPath
    Optional path to a .csv file to write the results to.

.EXAMPLE
    .\Get-KeyboardReport.ps1

.EXAMPLE
    .\Get-KeyboardReport.ps1 -ExportPath C:\Reports\keyboard.csv
#>

[CmdletBinding()]
param(
    [string]$ExportPath
)

$items = Get-CimInstance -ClassName Win32_Keyboard | Select-Object Description, Layout, NumberOfFunctionKeys

if (-not $items) {
    Write-Host "No Keyboard Info found." -ForegroundColor Yellow
    return
}

$items | Format-Table -AutoSize

if ($ExportPath) {
    $items | Export-Csv -Path $ExportPath -NoTypeInformation -Encoding UTF8
    Write-Host "`nExported to $ExportPath" -ForegroundColor Cyan
}