PowerShell Genie

Collect hardware summary

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Collect CPU model, RAM in GiB, and BIOS version with Get-CimInstance, then combine the results into one PowerShell object.

The script

1PS> [pscustomobject]@{Computer= $env:COMPUTERNAME;CPU=(Get-CimInstance Win32_Processor | Select-Object -Expand Name -First 1);RAMGB= [math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory/1GB, 1);BIOS=(Get-CimInstance Win32_BIOS).SMBIOSBIOSVersion}

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 Computer CPU RAMGB BIOS
    2 -------- --- ----- ----
    3 WS01 12th Gen Intel Core i7-12700 32.0 1.24.0
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    [pscustomobject]@{Computer= $env:COMPUTERNAME;CPU=(Get-CimInstance Win32_Processor | Select-Object -Expand Name -First 1);RAMGB= [math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory/1GB, 1);BIOS=(Get-CimInstance Win32_BIOS).SMBIOSBIOSVersion}
    1. Stage 1[pscustomobject]@{Computer=Positional values or no named parameters

      How it works

      A [pscustomobject] literal assembles the row in one shot. The CPU field pulls the first Name off Win32_Processor using -Expand so it lands as a string rather than a wrapper object, RAMGB reads TotalPhysicalMemory from Win32_ComputerSystem and converts with a 1GB divisor, and BIOS takes SMBIOSBIOSVersion from Win32_BIOS.

      Adapting it

      Wrap the literal in a function that accepts a computer name and pass it through to each Get-CimInstance call, which converts a single-host snapshot into something you can run down an inventory list.

      If the result is unexpected

      The hardware row is missing CPU or BIOS details, or RAM differs from the installed capacity.

      CPU, memory and BIOS values come from separate CIM classes; firmware reservations and multiple processors affect the summary.

      1. Query each CIM class separately and inspect its returned properties before assembling the row.

      Validate the result

      The row identifies the intended computer and matches the individual CIM results.

      Keep the check reliable

      Record the queried computer and distinguish OS-visible memory from purchased capacity.

      Primary documentation

      Get-CimInstance reference

      Continue
      Genie guideCollect hardware summary

      Collect CPU model, RAM in GiB, and BIOS version with Get-CimInstance, then combine the results into one PowerShell object.