Quote | Posted on
If you want to find out the computer model you can running this command below :
wmic csproduct get vendor, version
or we can get computer name , model, manufacturer and system type by using below command :
wmic computersystem get model,name,manufacturer,systemtype
source :
http://www.windows-commandline.com/get-computer-model/
If you are attempting to find out the serial number of manufacturer of a remote server you can do this via command line, using a WMIC (Windows Management Instrumentation Command-Line) cmdlet.
To find the Serial Number – wmic bios get serialnumber
To find the manufacturer – wmic computersystem get manufacturer
To Find the Model – wmic csproduct get name
I know many people have already figured it out in powershell way. I got similar requirement today morning where I have to check hardware make and model of 10 servers. That made me to recollect one of my old experience where I wrote a VB script to do the task. That time it took almost 2-3 hours to make the script ready. It took so long because of two reasons, number#1 I am new to VB scripting, number#2, I don’t know how to get this information. But it didn’t take that long today because of powershell as number#1 is not valid as I already gained some knowledge and number# as I already know from where I should get this info. So, I wrote below code in three minutes and gathered the output.
function get-hwinfo {
param($computer)
gwmi -query “select * from win32_computersystem” -computername $computer | select Name, Manufacturer, Model
}
$servers = Get-Content c:tempservers.txt
$servers | % { Get-hwinfo -computer $_ }
Hope this little code help you to pull the required information from servers. I will try to write a script to gather complete hardware configuration when I get some time.
Do you have a complete script which can get full hardware details? Share it.
### Powershell script gives Manufacturer and Server Model for a given list of servers, and we can find if its a VM or a physical server.
### eg: for a VM, manufacturer will be “VMware, Inc.”, and model will be “VMware Virtual Platform”
### eg: for a physical server, manufacturer will be “HP” (or others), and model will be “ProLiant BL460c G7”
### Servers which we failed to connect to get any info are collected in to a txt file.
### writing credits : VM ###
#######################################################################################
$servers = Get-Content “D:\temp\test2.txt”
$result = @()
$finalresult = @()
foreach ($computer in $servers)
{
$result = Get-WmiObject -Class Win32_ComputerSystem -ComputerName $computer | select pscomputername, manufacturer, model
$finalresult+=$result
if (!$result) { Write “No info on server $computer” | out-file -Append “D:\temp\notfound-phy-vm.txt” -NoClobber }
$computer = $null
$result = $null
}
$finalresult | export-csv “D:\temp\VMphys-1.csv” -NoTypeInformation
Опубликовано: 22.11.2011
Автор: Виталий Бочкарев
Поддержать автора статьи по этой ссылке
Недавно понадобилось собрать информацию о характеристиках серверов в удаленных сайтах, а так как серверов несколько десятков, то потребовалась некоторая автоматизация процесса сбора данных. Для сбора данных с группы серверов я использовал скрипт PowerShell, который представлен ниже.
# Функция сбора параметров с сервера Function GetComputerInfo ($ComputerName) { $ComputerProperties = New-Object System.Object $ComputerProperties | add-member -membertype noteproperty -name Name -Value $ComputerName $P = Get-WmiObject -class "Win32_ComputerSystem" -computername $ComputerName | ` Select Model, @{Label="TotalPhysicalMemory";Expression={[Math]::Round($_.TotalPhysicalMemory ` / 1024 / 1024 / 1024)}} $ComputerProperties | Add-Member -MemberType NoteProperty -Name Model -Value $Null $ComputerProperties.Model = $P.Model $ComputerProperties | Add-Member -MemberType NoteProperty -Name RAMSize -Value $Null $ComputerProperties.RAMSize = $P.TotalPhysicalMemory $P = Get-WmiObject -class "Win32_SystemEnclosure" -computername $ComputerName | select SerialNumber $ComputerProperties | Add-Member -MemberType NoteProperty -Name SerialNumber -Value $Null $ComputerProperties.SerialNumber = $P.SerialNumber $P = Test-Connection -ComputerName $ComputerName -Count 1 | select IPV4Address $ComputerProperties | Add-Member -MemberType NoteProperty -Name IPV4Address -Value $Null $ComputerProperties.IPV4Address = $P.IPV4Address $P = Get-WmiObject -class "Win32_Processor" -computername $ComputerName | ` Select Name, CurrentClockSpeed $ComputerProperties | Add-Member -MemberType NoteProperty -Name CPUName -Value $Null $ComputerProperties.CPUName = $P[0].Name $ComputerProperties | Add-Member -MemberType NoteProperty -Name CPUCores -Value $Null $ComputerProperties.CPUCores = ($P | Measure-Object).Count $ComputerProperties | Add-Member -MemberType NoteProperty -Name CPUClockSpeed -Value $Null $ComputerProperties.CPUClockSpeed = $P[0].CurrentClockSpeed $P = Get-WmiObject -class "Win32_DiskDrive" -computername $ComputerName | ` Select @{Label="HDDModel";Expression={$_.Model}}, ` @{Label="HDDInterfaceType";Expression={$_.InterfaceType}}, ` @{Label="HDDSize";Expression={[Math]::Round($_.Size / 1024 / 1024 / 1024)}}, ` @{Label="HDDPartitions";Expression={$_.Partitions}} $ComputerProperties | Add-Member -MemberType NoteProperty -Name HDD -Value $Null $ComputerProperties.HDD = $P $ComputerProperties } # Тело скрипта $ErrorActionPreference = "Continue" $Servers = Import-Csv Servers.csv $Servers | Sort name | Where-Object {Test-Connection -Count 2 -ComputerName $_.Name ` -ErrorAction SilentlyContinue} | ForEach-Object { GetComputerInfo $_.name }
Этот скрипт использует в качестве входных данных файл CSV, в котором перечислены имена серверов, с которых требуется собрать данные.
Листинг файла Servers.csv:
Name Server1 Server2 Server3 Server4
На выходе скрипта получается список табличек по каждому серверу, в которых указаны следующие параметры: имя сервера, модель сервера, размер ОЗУ в ГБ, серийный номер сервера, IP адрес сервера, тип процессора, количество ядер процессора, такторая частота процессора, информация по жестким дискам.
Например:
Name : Server1 Model : ProLiant ML370 G4 RAMSize : 2 SerialNumber : GB850964TF IPV4Address : 172.31.17.1 CPUName : Intel(R) Xeon(TM) CPU 3.60GHz CPUCores : 2 CPUClockSpeed : 3600 HDD : {@{HDDModel=HP LOGICAL VOLUME SCSI Disk Device; HDDInterfaceType=SCSI; HDDSize=34; HDDPartitions=4}, @{HDDModel=HP LOGICAL VOLUME SCSI Disk Device; HDDInterfaceType=SCSI; HDDSize=203; HDDPartitions=1}}