A friend and former colleague asked me about a way to obtain rather detailed information on the type and number of CPUs installed in a server, as well as the number of cores present.
This is the function I came up with.
Please note that this function is incapable of coping nicely with limitations implemented using /NUMPROC in boot.ini
The function should work on Windows 2000 Server and above.
function GetCPUinfo {
param ([array]$servernames = ".")
foreach ($servername in $servernames) {
[array]$wmiinfo = Get-WmiObject Win32_Processor -computer $servername
$cpu = ($wmiinfo[0].name) -replace ' +', ' '
$description = $wmiinfo[0].description
$cores = ( $wmiinfo | Select SocketDesignation | Measure-Object ).count
$sockets = ( $wmiinfo | Select SocketDesignation -unique | Measure-Object ).count
Switch ($wmiinfo[0].architecture) {
0 { $arch = "x86" }
1 { $arch = "MIPS" }
2 { $arch = "Alpha" }
3 { $arch = "PowerPC" }
6 { $arch = "Itanium" }
9 { $arch = "x64" }
}
$manfg = $wmiinfo[0].manufacturer
$obj = New-Object Object
$obj | Add-Member Noteproperty Servername -value $servername
$obj | Add-Member Noteproperty CPU -value $cpu
$obj | Add-Member Noteproperty Description -value $description
$obj | Add-Member Noteproperty Sockets -value $sockets
$obj | Add-Member Noteproperty Cores -value $cores
$obj | Add-Member Noteproperty Architecture -value $arch
$obj | Add-Member Noteproperty Manufacturer -value $manfg
$obj
}
}
The function is invoked with a list of servers as the single parameter. If no parameter is specified, the local server "." is used.
$result = GetCPUinfo server1, server2, server3
The output can then be piped info a Format-Table or similar.
$result | format-table -auto
The result could look something like this:
Servername CPU Description Sockets Cores Architecture Manufacturer
---------- --- ----------- ------- ----- ------------ ------------
server1 Intel(R) Xeon(TM) CPU 2.80GHz EM64T Family 15 Model 4 Stepping 8 4 16 x64 GenuineIntel
server2 Intel(R) Core(TM)2 CPU 6400 @ 2.13GHz EM64T Family 6 Model 15 Stepping 6 1 2 x64 GenuineIntel
server3 AMD Opteron(tm) Processor 285 AMD64 Family 15 Model 33 Stepping 2 2 2 x64 AuthenticAMD
server4 Intel(R) Xeon(R) CPU E7340 @ 2.40GHz EM64T Family 6 Model 15 Stepping 8 2 2 x64 GenuineIntel
server5 Intel(R) Xeon(R) CPU E7340 @ 2.40GHz EM64T Family 6 Model 15 Stepping 11 4 16 x64 GenuineIntel
server6 Intel(R) Xeon(TM) CPU 2.80GHz x86 Family 15 Model 4 Stepping 8 1 1 x86 GenuineIntel
server7 Pentium III Tualatin x86 Family 6 Model 11 Stepping 1 2 2 x86 GenuineIntel
PS
Please let me know if you find any limitations or has suggestions for improvement.
Wednesday, May 20, 2009
Subscribe to:
Post Comments (Atom)
1 comment:
I've found that windows is incapable of reporting a 64-bit CPU, when running a 32-bit OS.
Post a Comment