Problem Statement:

I have a lot of servers on my network and my manager comes and tell me, “Can you get me details like the total RAM, HDD, Manufacturer, Serial Number and ServerName of all these servers?? I need to report this to Infrastructure team! Please get this in 2 hours time!!” Sounds laborious..Isn’t it??

Here's the script:
 "IP`tHardDisk`tRAM`tSystemName`tManufacturer`tSerialNumber" out-file C:\Results.csv -append

Function HDDInfo {
$alldrives = get-wmiobject win32_logicaldisk -filter "DriveType=3" -computername $ip
$HDD = 0
foreach ($i in $alldrives) { $HDD = $HDD + ($i.size)/(1gb) }
$HDD }

Function RAMInfo {
$ram = get-wmiobject win32_ComputerSystem -computername $ip
$RAM = ($ram.TotalPhysicalMemory)/(1gb)
$RAM }

Function SystemName {
$bios = get-wmiobject win32_bios -computer $ip
$ }

Function Manufacturer {
$bios = get-wmiobject win32_bios -computer $ip
$bios.manufacturer }

Function SerialNumber {
$bios = get-wmiobject win32_bios -computer $ip
$bios.SerialNumber }

$address = "10.2.2."
2..254 foreach-object { $ip = $address + $_
$ping = get-wmiobject win32_pingstatus -filter "Address = '$ip'" select-object statuscode
if($ping.statuscode -eq 0) {
$HDD = HDDInfo $ip
sleep 1
$RAM = RAMInfo $ip
sleep 1
$SystemName = SystemName $ip
$Manufacturer = Manufacturer $ip
$SerialNumber = SerialNumber $ip
"$ip`t$HDD`t$RAM`t$SystemName`t$Manufacturer`t$SerialNumber" out-file C:\Results.csv -append }
else { "$ip is Offline or Not Reachable.." out-file C:\Results.csv -append }

In this script, I assume all your systems on the network are

in the IP range of 10.2.2.x and

I am collecting the details of IPs: -

Run the script, wait for 4-5 minutes and get the results in Results.csv file. 🙂