PowerShell: getting facts about your PC

# PowerShell script to return a) disk size, b) free space for the supplied list of servers.
# Edit the values below for the known servers ($remoteServerSet) and known drives ($driveSet)

$remoteServerSet = “localhost”,”dennis-pc”
$driveSet = “C:”,”E:”

# no editing below this line…
Write-Host “Gathering server information…” -ForegroundColor Blue
$remoteServerSet | foreach {
$currentServer = $_
Write-Host “`tProcessing server: [$currentServer]…”-ForegroundColor Yellow

$serverProps = Get-WmiObject win32_Processor -ComputerName $currentServer
“MaxClockSpeed: $($serverProps.MaxClockSpeed)”
“NumberOfCores: $($serverProps.NumberOfCores)”
“NumberOfLogicalProcessors: $($serverProps.NumberOfLogicalProcessors)”

$driveSet | foreach {
$currentDrive = $_
“Processing drive: [$currentDrive]…”
$disk = Get-WmiObject Win32_LogicalDisk -ComputerName $currentServer -Filter “DeviceID=’$currentDrive'”
$diskSize = [int] $($disk.Size/1GB)
“`tDisk size: $($diskSize) GB”
$diskFreeSpace = [int] $($disk.FreeSpace/1GB)
“`tDisk free space: $($diskFreeSpace) GB”

}

}

 

Advertisements