In SQL Server Management Studio 2008 (executed on the server where you want the information) right click anywhere in the object explorer tree under that server and select Start PowerShell. Then paste the command I showed below. Alternatively you can just run Powershell.exe on the server, and paste that command and get the desired results
Let’s write function named GetCpuinfo.
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
}
}
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 Get-WMIObject cmdlet enables you to get any WMI object. You can also use Get-WMIObject to list out the WMI classes present to aid in discovery. #
Function is called with a listing of servers as the single parameter. If parameter is not specified, the local server "." is used.
$result = GetCPUinfo server1, server2, server3
the output can then be showed into a Format-Table or similar.
$result | format-table -auto
Output should be look like this.
No comments:
Post a Comment