Grabbing CPU info from AD Computers

I’m looking to grab the CPU Model information from various Computers on my Local AD Network. and I was wondering if this was possible. Right now I have a script to grab all the copmuters and their OSs on the domain, and I’ve been able to grab my computer’s CPU info, but not much more than that. Here’s my code so far. Have any ideas? All computer names and location data have been redacted due to company policies.

#LIST ALL COPMUTERS FROM LOCATION, THIER IPAS, AND OS

#VARIABLES FOR COUNTING THE NUMBER OF COMPUTERS
$WS = Get-ADComputer -Filter ‘Name -like “SV1*” -or Name -like “SV2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$WS2 = Get-ADComputer -Filter ‘Name -like “SV3*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$WX = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$W1 = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$W7 = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$XP = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$WP = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem
$UnL = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem

#LIST ALL WINDOWS 10 COPMUTERS

#Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem

#LIST ALL WINDOWS 7 COMPTUERS
#Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem

#LIST ALL WINDOWS 11 COMPUTERS
#Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “PC2*”’ -Properties IPv4Address, OperatingSystem | Select Name, IPv4Address, OperatingSystem

#COUNTING THE NUMBER OF OS COMPUTERS
$WS = $WS.count
$WS2 = $WS2.count

#ADDING THE SERVER COUNTS TOGETHER
$WS = $WS + $WS2

$W1 = $W1.count
$WX = $WX.count
$W7 = $W7.count
$XP = $XP.count
$WP = $WP.count
$UnL = $UnL.count

#SUBTRACING THE SERVERS FROM UnNamed COMPUTERS COUNT
$TotalCount = $W1 + $WX + $W7 + $XP + $WP + $WS

$UnL = $UnL - $WS
$UnL = $UnL - $TotalCount

#SUBTRACING THE SERVERS FROM UnNamed COMPUTERS COUNT
#$UnL = $UnL - $WS
#$UnL = $UnL - $TotalCount

Write-Host "Windows Servers: " $WS
Write-Host "Windows 11 Computers: " $W1
Write-Host "Windows 10 Computers: " $WX
Write-Host "Windows 7 Computers: " $W7
Write-Host "Windows XP Computers: " $XP
Write-Host "Windows 2000 Computers: " $WP
#Write-Host "UnNamed Computers: " $UnL
Write-Host " "
Write-Host "Total number of Active Computers: " $TotalCount

#$ComputerList = Get-ADComputer -Filter ‘Name -like "PC1*’" -or Name -like “PC2*”’ | Select Name

#$CPUSearchSession = New-PSSession -ComputerName $ComputerList

#icm $ComputerList {get-wmiobject Win32_Processor | Select Name}

#ForEach $ComputerSearchList {
#$ComputerSearchList = Get-ADComputer -Filter ‘Name -like “PC1*” -or Name -like “ALKLS*”’ | Select Name
#Get-WmiObject -Class Win32_Processor -ComputerName $ComputerSearchList
#}

Start-Sleep

#$ComputerSearchList = Get-ADComputer -Filter ‘Name -like “PC1*”’ | Select Name
#$ComputerSearchList | ForEach-Object {

$ComputerSearchList = Get-ADComputer -Filter ‘Name -like “PC1*”’ | Select Name

Get-WmiObject -Class Win32_Processor | Select Name

#}

For ((i=0) (i -lt $TotalCount), (i++)) {
Get-WmiObject -Class Win32_Processor -ComputerName “PC1*” | Select Name
}

#COULD USE THE COUNT OF TOTAL COMPUTERS AS A LOOP INT AND TEST
#TO SEE IF THE COMPUTER NAME EXISTS, IF IT DOESN’T, ADD 1 TO INT NUMBER
#AND KEEP RUNNING THROUGH THE LOOP UNTILL ALL COUMPUTER NAMES HAVE
#BEEN LOOPED THROUGH AND CHECKED FOR CPU NAME

Start-Sleep

TronyBoy82,
Welcome to the forum. :wave:t3:

That’s a lot of code for such a small task … and it is completely unformatted. Before we proceed … please go back, edit your question once again and fix the formatting of your code.

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org 1 <---- Click :point_up_2:t4: :wink:

The code was really not nessesary. Add -Computername to Get-Wmiobject

This code is way too long, and it looks like you are doing the same query over and over again.
I strongly suggest you to use -match to do string comparaison. Regexp is a tough to learn, but once mastered, it is going to be your best friend.
I also suggest to use grouping

$obj1,$obj2 | > Group-Object -Property OS

Grouping will automatically put items together, and add a count to your queries.

You can also use the command Measure-Object -Sum