Find CPU, Memory and Volume Info

Posted by

Introduction:

As a Wintel admin you might come across a situation where you want specific information about CPU, Memory and Volume information for multiple servers.

The script below is a quick way to find this info

Prerequisite:

  1. The user that runs this script must have local administrator access on the remote system
  2. You need to have a list of host names or IPs for the  remote systems
  3. PowerShell version 5 or above

Code:

Remove-Item $env:USERPROFILE\Documents\MemInfo.csv $env:USERPROFILE\Documents\CpuInfo.csv $env:USERPROFILE\Documents\DiskInfo.csv
Start-Transcript $env:USERPROFILE\Documents\findSysInfo.log
$SystemNames = Get-Content $env:USERPROFILE\Documents\Systemlist.txt
echo "SystemName,BankLabel,Capacity,DeviceLocator,Speed" > $env:USERPROFILE\Documents\MemInfo.csv
foreach ($SystemName in $SystemNames)
{
$CpuInfo = Get-WmiObject -ComputerName $SystemName -class win32_processor -Property SystemName,Manufacturer,DeviceID,MaxClockSpeed,NumberOfCores,NumberOfLogicalProcessors | Select-Object SystemName,Manufacturer,DeviceID,MaxClockSpeed,NumberOfCores,NumberOfLogicalProcessors | Export-Csv -Append -NoTypeInformation $env:USERPROFILE\Documents\CpuInfo.csv
$DiskInfo = Get-WmiObject -ComputerName $SystemName -Class Win32_Volume -Property SystemName,DriveLetter,Label,BootVolume,BlockSize,FileSystem,Capacity,FreeSpace | Select-Object SystemName,DriveLetter,Label,BootVolume,BlockSize,FileSystem,Capacity,FreeSpace | Export-Csv -Append -NoTypeInformation $env:USERPROFILE\Documents\DiskInfo.csv
$MemInfo = Get-WmiObject -ComputerName $SystemName -Class Win32_PhysicalMemory -Property BankLabel,Capacity,DeviceLocator,Speed | Select-Object BankLabel,Capacity,DeviceLocator,Speed
    foreach($Obj in $MemInfo )
    {
       $BankLabel = $Obj.BankLabel
       $Capacity = $Obj.Capacity
       $DeviceLocator = $Obj.DeviceLocator
       $Speed = $Obj.Speed
       echo $SystemName','$BankLabel','$Capacity','$DeviceLocator','$Speed >>$env:USERPROFILE\Documents\MemInfo.csv
    }
}
Stop-Transcript