Powershell - Quickly get machine specs.

Sometimes there are tasks that you get asked to do at work that are annoying, and can waste a lot of time. 

A great example is, "Hey, we're doing capacity planning, can you give me the Cores, RAM, and Disks for the following 84 servers?" Oh god...

Luckily for us, Powershell! I assembled this little guy that outputs the number of cores, memory, and Disks (Letters and Sizes) into a neat little copy and paste-able output. 

#Return Disks, Cores, and RAM provisioned to a server or servers.
#JWS 2015

#Functions defined to return Specs
function RAM ($server) {
$memory = Get-WMIObject -class Win32_PhysicalMemory -ComputerName $server | Measure-Object -Property capacity -Sum | % {[Math]::Round(($_.sum / 1GB),2)}
return "Memory: $memory GB"

function CPU ($server) {
$processors = get-wmiobject -computername $server win32_processor
if (@($processors)[0].NumberOfCores)
$cores = @($processors).count * @($processors)[0].NumberOfCores
$cores = @($processors).count
return "Cores: $cores"

function Disk ($server) {
GET-WMIOBJECT –query “SELECT * from win32_logicaldisk where DriveType = 3” -computerName $server | Select-Object DeviceID,
@{Name = "Size (GB)"; Expression = { "{0:N1}" -f ($_.size / 1GB ) } } | Format-Table -AutoSize


$servers = gc C:\Scripts\txt\list.txt

ForEach ($server in $servers) {

Write-Host "Specs for $server are..."
CPU ($server)
RAM ($server)
Write-Host "Disks:"
Disk ($server)

Throw a list of servers into the referenced text file in the forEach loop, and you've saved yourself a bunch of time. 

Output looks like this:

Specs for servername are...
Cores: 2
Memory: 4 GB
DeviceID Size (GB)
--------       ---------
C:               103.9
D:               48.8