How to check physical CPU count and server status (PHYSICAL or VIRTUAL) for bulk server's ?
Solution: Power Shell Script.
Create a file servername.txt in local script path having server's name.
function Get-CPUs {
param ($server, $username)
if ($username)
{
$processors = get-wmiobject -computername $server -credential $username win32_processor
}
else
{
$processors = get-wmiobject -computername $server win32_processor
}
if (@($processors)[0].NumberOfCores)
{
$cores = @($processors).count * @($processors)[0].NumberOfCores
}
else
{
$cores = @($processors).count
}
$sockets = @(@($processors) |
% {$_.SocketDesignation} |
select-object -unique).count;
$objWMI = $NULL
$bln = $NULL
$objWMI = Get-WmiObject -computername $server Win32_ComputerSystem
Write-Host –NoNewLine $server, CORE, $cores, SOCKET, $sockets, $objWMI.manufacturer, $objWMI.model -ForegroundColor "YELLOW"
Write-host ("");
}
# Get server list
$servers = Get-Content "servername.txt";
$datetime = Get-Date -Format "yyyyMMddHHmmss";
foreach($server in $servers)
{
Get-CPUs $server
}
Solution: Power Shell Script.
Create a file servername.txt in local script path having server's name.
function Get-CPUs {
param ($server, $username)
if ($username)
{
$processors = get-wmiobject -computername $server -credential $username win32_processor
}
else
{
$processors = get-wmiobject -computername $server win32_processor
}
if (@($processors)[0].NumberOfCores)
{
$cores = @($processors).count * @($processors)[0].NumberOfCores
}
else
{
$cores = @($processors).count
}
$sockets = @(@($processors) |
% {$_.SocketDesignation} |
select-object -unique).count;
$objWMI = $NULL
$bln = $NULL
$objWMI = Get-WmiObject -computername $server Win32_ComputerSystem
Write-Host –NoNewLine $server, CORE, $cores, SOCKET, $sockets, $objWMI.manufacturer, $objWMI.model -ForegroundColor "YELLOW"
Write-host ("");
}
# Get server list
$servers = Get-Content "servername.txt";
$datetime = Get-Date -Format "yyyyMMddHHmmss";
foreach($server in $servers)
{
Get-CPUs $server
}
No comments:
Post a Comment