System Info
# Get-SystemInfo.ps1
# Broad system inventory that stays open until a key is pressed.
$ErrorActionPreference = "Continue"
$ShowRawComputerInfo = $true # Change to $false if you want a shorter report
Clear-Host
function Show-Section {
param([string]$Title)
Write-Host ""
Write-Host ("=" * 90) -ForegroundColor DarkCyan
Write-Host $Title -ForegroundColor Cyan
Write-Host ("=" * 90) -ForegroundColor DarkCyan
}
function Format-Bytes {
param([Nullable[Double]]$Bytes)
if ($null -eq $Bytes) { return "" }
if ($Bytes -ge 1TB) { return "{0:N2} TB" -f ($Bytes / 1TB) }
if ($Bytes -ge 1GB) { return "{0:N2} GB" -f ($Bytes / 1GB) }
if ($Bytes -ge 1MB) { return "{0:N2} MB" -f ($Bytes / 1MB) }
if ($Bytes -ge 1KB) { return "{0:N2} KB" -f ($Bytes / 1KB) }
return "{0:N0} Bytes" -f $Bytes
}
function Format-DateTime {
param($Value)
if ($null -eq $Value -or $Value -eq "") { return "" }
try {
return ([DateTime]$Value).ToString("yyyy-MM-dd HH:mm:ss")
}
catch {
return [string]$Value
}
}
function Wait-ForKey {
Write-Host ""
Write-Host "Press any key to close..." -ForegroundColor Yellow
try {
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
}
catch {
try {
$null = [System.Console]::ReadKey($true)
}
catch {
[void](Read-Host "Press Enter to close")
}
}
}
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
[Security.Principal.WindowsBuiltInRole]::Administrator
)
if (-not $isAdmin) {
Write-Warning "Not running as Administrator. Some details may be missing."
}
$os = Get-CimInstance Win32_OperatingSystem
$cs = Get-CimInstance Win32_ComputerSystem
$bios = Get-CimInstance Win32_BIOS
$baseboard = Get-CimInstance Win32_BaseBoard
$cpu = Get-CimInstance Win32_Processor
$memoryModules = Get-CimInstance Win32_PhysicalMemory | Sort-Object BankLabel, DeviceLocator
$diskDrives = Get-CimInstance Win32_DiskDrive
$logicalDisks = Get-CimInstance Win32_LogicalDisk -Filter "DriveType = 3"
$videoControllers = Get-CimInstance Win32_VideoController
$uptime = New-TimeSpan -Start $os.LastBootUpTime -End (Get-Date)
$totalMemory = ($memoryModules | Measure-Object -Property Capacity -Sum).Sum
Show-Section "SYSTEM SUMMARY"
[pscustomobject]@{
ComputerName = $env:COMPUTERNAME
LoggedOnUser = "$env:USERDOMAIN\$env:USERNAME"
Manufacturer = $cs.Manufacturer
Model = $cs.Model
SerialNumber = $bios.SerialNumber
SystemType = $cs.SystemType
OS = $os.Caption
OSVersion = $os.Version
BuildNumber = $os.BuildNumber
LastBoot = Format-DateTime $os.LastBootUpTime
Uptime = "{0} days {1} hours {2} minutes" -f $uptime.Days, $uptime.Hours, $uptime.Minutes
TotalMemory = Format-Bytes $totalMemory
} | Format-List | Out-Host
Show-Section "OPERATING SYSTEM"
[pscustomobject]@{
Caption = $os.Caption
Version = $os.Version
BuildNumber = $os.BuildNumber
Architecture = $os.OSArchitecture
InstallDate = Format-DateTime $os.InstallDate
LastBootUpTime = Format-DateTime $os.LastBootUpTime
SerialNumber = $os.SerialNumber
RegisteredUser = $os.RegisteredUser
Organization = $os.Organization
WindowsDirectory = $os.WindowsDirectory
SystemDirectory = $os.SystemDirectory
Locale = $os.Locale
} | Format-List | Out-Host
Show-Section "BIOS / MOTHERBOARD"
[pscustomobject]@{
BIOSManufacturer = $bios.Manufacturer
BIOSVersion = $bios.SMBIOSBIOSVersion
ReleaseDate = Format-DateTime $bios.ReleaseDate
SerialNumber = $bios.SerialNumber
BaseBoardMaker = $baseboard.Manufacturer
BaseBoardProduct = $baseboard.Product
BaseBoardVersion = $baseboard.Version
} | Format-List | Out-Host
Show-Section "CPU"
$cpu |
Select-Object DeviceID, Name, Manufacturer, SocketDesignation, NumberOfCores, NumberOfLogicalProcessors,
@{Name="MaxClockGHz"; Expression = { [math]::Round($_.MaxClockSpeed / 1000, 2) }} |
Format-Table -AutoSize | Out-Host
Show-Section "MEMORY"
[pscustomobject]@{
TotalInstalledMemory = Format-Bytes $totalMemory
MemorySlotsDetected = $memoryModules.Count
} | Format-List | Out-Host
$memoryModules |
Select-Object BankLabel, DeviceLocator, Manufacturer, PartNumber,
@{Name="CapacityGB"; Expression = { [math]::Round($_.Capacity / 1GB, 2) }},
Speed, ConfiguredClockSpeed, SerialNumber |
Format-Table -AutoSize | Out-Host
Show-Section "PHYSICAL DISKS"
$diskDrives |
Select-Object Model, InterfaceType, MediaType,
@{Name="Size"; Expression = { Format-Bytes $_.Size }},
SerialNumber |
Format-Table -AutoSize | Out-Host
Show-Section "LOGICAL DRIVES / VOLUMES"
$logicalDisks |
Select-Object DeviceID, VolumeName, FileSystem,
@{Name="Size"; Expression = { Format-Bytes $_.Size }},
@{Name="Free"; Expression = { Format-Bytes $_.FreeSpace }},
@{Name="FreePct"; Expression = {
if ($_.Size -gt 0) {
"{0:N1}%" -f (($_.FreeSpace / $_.Size) * 100)
}
else {
""
}
}} |
Format-Table -AutoSize | Out-Host
Show-Section "VIDEO"
$videoControllers |
Select-Object Name, DriverVersion,
@{Name="AdapterRAM"; Expression = { Format-Bytes $_.AdapterRAM }},
VideoProcessor, CurrentHorizontalResolution, CurrentVerticalResolution |
Format-Table -AutoSize | Out-Host
Show-Section "NETWORK"
if (Get-Command Get-NetIPConfiguration -ErrorAction SilentlyContinue) {
$netInfo = Get-NetIPConfiguration |
Where-Object { $_.NetAdapter.Status -ne "Disabled" } |
ForEach-Object {
[pscustomobject]@{
Adapter = $_.InterfaceAlias
Status = $_.NetAdapter.Status
MACAddress = $_.NetAdapter.MacAddress
LinkSpeed = $_.NetAdapter.LinkSpeed
DHCP = $_.NetIPv4Interface.Dhcp
IPv4Address = ($_.IPv4Address | ForEach-Object { $_.IPAddress }) -join ", "
IPv6Address = ($_.IPv6Address | ForEach-Object { $_.IPAddress }) -join ", "
Gateway = ($_.IPv4DefaultGateway | ForEach-Object { $_.NextHop }) -join ", "
DNSServers = ($_.DNSServer.ServerAddresses) -join ", "
}
}
$netInfo | Format-List | Out-Host
}
else {
Get-CimInstance Win32_NetworkAdapterConfiguration -Filter "IPEnabled = True" |
Select-Object Description, MACAddress, DHCPEnabled,
@{Name="IPAddress"; Expression = { ($_.IPAddress) -join ", " }},
@{Name="DefaultGateway"; Expression = { ($_.DefaultIPGateway) -join ", " }},
@{Name="DNSServers"; Expression = { ($_.DNSServerSearchOrder) -join ", " }} |
Format-List | Out-Host
}
Show-Section "RECENT HOTFIXES"
Get-HotFix |
Sort-Object InstalledOn -Descending |
Select-Object -First 20 HotFixID, Description, InstalledOn |
Format-Table -AutoSize | Out-Host
if ($ShowRawComputerInfo -and (Get-Command Get-ComputerInfo -ErrorAction SilentlyContinue)) {
Show-Section "RAW GET-COMPUTERINFO OUTPUT"
Get-ComputerInfo | Format-List * | Out-Host
}
Wait-ForKey