Jump to page sections
- Getting Computer Model As Reported by the System BIOS
- From WSUS
- Sample Output
- Script Code
- Using CIM/WMI
- Using PsExec
- Old Script Code
One approach could be using a computer with PowerShell version 3 or higher so you have the "PSComputerName" property returned from Invoke-Command, set up PSRemoting, which also works against PowerShell version 2, and run something like you see below.
Scroll down or click the table of contents to go to CIM/WMI approaches. CIM requires PSv3 (Windows Management Framework 3) on the target computers. WMI works (can work) even if the remote computer doesn't have PowerShell, but that's becoming a rarity fast.PS C:\> Invoke-Command -ErrorVariable myerr -ErrorAction Silent -Cn (Get-ADComputer -Filter * | % Name) `
-Script { gwmi win32_computersystem | % { "$($_.Manufacturer) $($_.Model)" } } |
Select-Object -Property PSComputerName, @{n='ComputerModel'; e={ $_ }} |
Format-Table -AutoSize
PSComputerName ComputerModel
-------------- -------------
2012R2 Microsoft Corporation Virtual Machine
WIN7PSV3 Microsoft Corporation Virtual Machine
WIN7 Microsoft Corporation Virtual Machine
ELITEBOOK2015 Hewlett-Packard HP EliteBook 840 G2
DELL2010 Dell Inc. Latitude E6420
STUEPC System manufacturer System Product Name
Getting Computer Model As Reported by the System BIOS
To see how to get a list of computers from Active Directory, see the following article: Getting Computer Names From AD Using PowerShell.
Here is the quick one-liner some of you might be looking for, so I will put it at the top:PS C:\> (gwmi Win32_ComputerSystem).Model LIFEBOOK S7010 PS C:\>
Or a slight variation, as demonstrated below.
''Side note: Most vendors like HP, Dell, Fujitsu-Siemens, etc. do label their motherboards, but with home-built computers you will often find that there's a default or non-descriptive name, like in this example. It's actually an Asus motherboard.''PS C:\> Get-WmiObject Win32_ComputerSystem | Select -Expand Model System Product Name PS C:\>
To target a remote computer, simply add the parameter "-ComputerName server01" to gwmi/Get-WmiObject.
Pipe to Get-Member instead of Select to see all properties, or Select * - or Format-List *.From WSUS
Sample Output
PS C:\powershell\wsus> .\get-wsus-models.ps1 > models.txt PS C:\powershell\wsus> type .\models.txt | Select-Object -first 10 Found 974 computers Found 127 unique models Name Value ---- ----- OptiPlex 760 64 HP Compaq dc7600 Small Form Factor 55 OptiPlex GX620 53 HP Compaq dc7900 Small Form Factor 49 HP Compaq 8000 Elite CMT PC 43
Script Code
[reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration") | Out-Null
# This function removes text between parentheses
function massageModel {
param([Parameter(Mandatory=$true)][string] $private:model)
$private:model = $private:model -replace '\s*\([^)]+\)\s*$', ''
$private:model = $private:model -replace '\s+$', ''
return $private:model
}
# Create a WSUS object
if (!$wsus) {
$wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::GetUpdateServer()
}
# Create a computer scope object and set the criteria to "All" update installation states
# to target all computers in the WSUS database.
$computerScope = New-Object Microsoft.UpdateServices.Administration.ComputerTargetScope
$computerScope.IncludedInstallationStates = [Microsoft.UpdateServices.Administration.UpdateInstallationStates]::All
# Get all the computer objects
$computers = $wsus.GetComputerTargets($computerScope)
'Found ' + $computers.Count + ' computers'
# Initialize hash
$models = @{}
# Store "massaged" models in a hash (keys are unique)
# and count the number of models.
$computers | Foreach-Object { $model = massageModel $_.Model; $models.$model += 1 }
'Found ' + $models.count + ' unique models'
# Output the data, sorted with the most common models
# first and then alphabetically.
$models.GetEnumerator() |
Sort-Object -Property @{Expression='Value';Descending=$true},@{Expression='Name';Descending=$false} |
Format-Table -AutoSize
You can of course adapt this as necessary.
Using CIM/WMI
Find a computer with PowerShell version 3 or higher and just use something like this after you've set up PSRemoting. You can actually just replace "Get-CimInstance" with "Get-WmiObject" in this example to target systems without Windows Management Framework 3. I notice the Windows 7 computer I installed PSv3 on responds to the CIM cmdlet as well.
Screenshot example:
PS C:\> $res = Get-CimInstance -Cn (Get-ADComputer -Filter * | % Name) `
-Class Win32_ComputerSystem -EA Silent -ErrorVar myerr |
Select PSComputerName, @{ Name = "ComputerModel"; Expression = {
"$($_.Manufacturer.Trim()) $($_.Model.Trim())" } }
PS C:\> $res.Count
6
PS C:\> $res | Format-Table -AutoSize
PSComputerName ComputerModel
-------------- -------------
2012R2 Microsoft Corporation Virtual Machine
SERVER2016 Microsoft Corporation Virtual Machine
WIN7PSV3 Microsoft Corporation Virtual Machine
STUEPC System manufacturer System Product Name
DELL2010 Dell Inc. Latitude E6420
ELITEBOOK2015 Hewlett-Packard HP EliteBook 840 G2
Using PsExec
PsExec isn't really a great approach, but here it is. As I mentioned at the top, this is an old article from an earlier stage of learning. I have later fixed it a bit with my Invoke-PsExec script module, but I doubt you want this. Then you can use WMI directly instead. Use Get-WmiObject instead of Invoke-Command like in the example at the top and adapt the rest.
PS C:\> # Install-Module -Name InvokePsExec # (if you have WMF 5 or WMF3 and nuget, etc.)
PS C:\> Invoke-PsExec -Cn 2012r2 -IsPS -Command 'gwmi win32_computersystem | % { "$($_.Manufacturer) $($_.Model)" }'
-HideSummary | Format-List ComputerName, STDOUT
ComputerName : 2012r2
STDOUT : Microsoft Corporation Virtual Machine
Old Script Code
This is obsolete!
*Download the script Get-models-psexec.ps1.txt *Download the VBScript it uses Get-model.zip *Go to Microsoft Technet - Sysinternals to download psexec.exe from the PsTools suite Powershell WSUS BIOS WMI CIM PSTools WindowsBlog articles in alphabetical order
A
- A Look at the KLP AksjeNorden Index Mutual Fund
- A primitive hex version of the seq gnu utility, written in perl
- Accessing the Bing Search API v5 using PowerShell
- Accessing the Google Custom Search API using PowerShell
- Active directory password expiration notification
- Aksje-, fonds- og ETF-utbytterapportgenerator for Nordnet-transaksjonslogg
- Ascii art characters powershell script
- Automatically delete old IIS logs with PowerShell
C
- Calculate and enumerate subnets with PSipcalc
- Calculate the trend for financial products based on close rates
- Check for open TCP ports using PowerShell
- Check if an AD user exists with Get-ADUser
- Check when servers were last patched with Windows Update via COM or WSUS
- Compiling or packaging an executable from perl code on windows
- Convert between Windows and Unix epoch with Python and Perl
- Convert file encoding using linux and iconv
- Convert from most encodings to utf8 with powershell
- ConvertTo-Json for PowerShell version 2
- Create cryptographically secure and pseudorandom data with PowerShell
- Crypto is here - and it is not going away
- Crypto logo analysis ftw
D
G
- Get rid of Psychology in the Stock Markets
- Get Folder Size with PowerShell, Blazingly Fast
- Get Linux disk space report in PowerShell
- Get-Weather cmdlet for PowerShell, using the OpenWeatherMap API
- Get-wmiobject wrapper
- Getting computer information using powershell
- Getting computer models in a domain using Powershell
- Getting computer names from AD using Powershell
- Getting usernames from active directory with powershell
- Gnu seq on steroids with hex support and descending ranges
- Gullpriser hos Gullbanken mot spotprisen til gull
H
- Have PowerShell trigger an action when CPU or memory usage reaches certain values
- Historical view of the SnP 500 Index since 1927, when corona is rampant in mid-March 2020
- How Many Bitcoins (BTC) Are Lost
- How many people own 1 full BTC
- How to check perl module version
- How to list all AD computer object properties
- Hva det innebærer at særkravet for lån til sekundærbolig bortfaller
I
L
M
P
- Parse openssl certificate date output into .NET DateTime objects
- Parse PsLoggedOn.exe Output with PowerShell
- Parse schtasks.exe Output with PowerShell
- Perl on windows
- Port scan subnets with PSnmap for PowerShell
- PowerShell Relative Strength Index (RSI) Calculator
- PowerShell .NET regex to validate IPv6 address (RFC-compliant)
- PowerShell benchmarking module built around Measure-Command
- Powershell change the wmi timeout value
- PowerShell check if file exists
- Powershell check if folder exists
- PowerShell Cmdlet for Splitting an Array
- PowerShell Executables File System Locations
- PowerShell foreach loops and ForEach-Object
- PowerShell Get-MountPointData Cmdlet
- PowerShell Java Auto-Update Script
- Powershell multi-line comments
- Powershell prompt for password convert securestring to plain text
- Powershell psexec wrapper
- PowerShell regex to accurately match IPv4 address (0-255 only)
- Powershell regular expressions
- Powershell split operator
- Powershell vs perl at text processing
- PS2CMD - embed PowerShell code in a batch file
R
- Recursively Remove Empty Folders, using PowerShell
- Remote control mom via PowerShell and TeamViewer
- Remove empty elements from an array in PowerShell
- Remove first or last n characters from a string in PowerShell
- Rename unix utility - windows port
- Renaming files using PowerShell
- Running perl one-liners and scripts from powershell
S
- Sammenlign gullpriser og sølvpriser hos norske forhandlere av edelmetall
- Self-contained batch file with perl code
- Silver - The Underrated Investment
- Simple Morningstar Fund Report Script
- Sølv - den undervurderte investeringen
- Sort a list of computers by domain first and then name, using PowerShell
- Sort strings with numbers more humanely in PowerShell
- Sorting in ascending and descending order simultaneously in PowerShell
- Spar en slant med en optimalisert kredittkortportefølje
- Spre finansiell risiko på en skattesmart måte med flere Aksjesparekontoer
- SSH from PowerShell using the SSH.NET library
- SSH-Sessions Add-on with SCP SFTP Support
- Static Mutual Fund Portfolio the Last 2 Years Up 43 Percent
- STOXR - Currency Conversion Software - Open Exchange Rates API