Skip to content

Instantly share code, notes, and snippets.

@tcartwright
Last active February 21, 2025 19:20
Show Gist options
  • Save tcartwright/8d1367800bd541bd0cbfdadc8befc236 to your computer and use it in GitHub Desktop.
Save tcartwright/8d1367800bd541bd0cbfdadc8befc236 to your computer and use it in GitHub Desktop.
POWERSHELL: Get system information
Clear-Host
$memInfo = Get-WmiObject Win32_PhysicalMemory
$diskInfo = Get-Disk | Sort-Object DiskNumber
$driveInfo = Get-Volume | Where-Object { $_.DriveLetter } | Sort-Object DriveLetter
Write-Host 'Get-ComputerInfo' -ForegroundColor Yellow
$computerInfo = Get-ComputerInfo | Select-Object `
@{Name="DNSHostName"; Expression={$_.CsDNSHostName}},
@{Name="Domain"; Expression={$_.CsDomain}},
@{Name="UserName"; Expression={$_.CsUserName}},
@{Name="Model"; Expression={$_.CsModel}},
OsName,
WindowsEditionId,
OSDisplayVersion,
OsProductType,
OsVersion,
OsBuildNumber,
OsArchitecture,
OsLanguage,
BiosSeralNumber,
BiosManufacturer,
BiosName,
TimeZone,
@{Name="OsInstallDate"; Expression={([DateTime]$_.OsInstallDate).ToString("yyyy-MM-dd HH:mm:ssK")}},
@{Name="OsLocalDateTime"; Expression={([DateTime]$_.OsLocalDateTime).ToString("yyyy-MM-dd HH:mm:ssK")}},
@{Name="OsLastBootUpTime"; Expression={([DateTime]$_.OsLastBootUpTime).ToString("yyyy-MM-dd HH:mm:ssK")}},
OsUptime,
@{Name="NumberOfProcessors"; Expression={$_.CsNumberOfProcessors}},
@{Name="NumberOfLogicalProcessors"; Expression={$_.CsNumberOfLogicalProcessors}},
@{Name="PhyicallyInstalledMemoryMB"; Expression={$_.CsPhyicallyInstalledMemory / 1MB}},
@{Name="FreePhysicalMemoryMB"; Expression={[math]::Round($_.OsFreePhysicalMemory / 1MB, 2)}},
@{Name="MemoryCount"; Expression={$memInfo.Count}},
@{Name="MemoryInfo"; Expression={
$memInfo | Select-Object DeviceLocator,
Manufacturer,
@{Name="PartNumber"; Expression={$_.PartNumber.Trim()}},
@{Name="CapacityMB"; Expression={$_.Capacity / 1MB}},
SerialNumber,
@{Name="Type"; Expression={$_.MemoryType}},
@{Name="BIOSType"; Expression={$_.SMBIOSMemoryType}},
@{Name="Speed"; Expression={$_.Speed}}
}},
@{Name="DiskCount"; Expression={$diskInfo.Count}},
@{Name="DiskInfo"; Expression={
$diskInfo | Select-Object DiskNumber,
ProvisioningType,
IsBoot,
@{Name="Status"; Expression={$_.OperationalStatus}},
HealthStatus,
BusType,
@{Name="SizeMB"; Expression={[math]::Round($_.Size / 1MB, 2)}},
@{Name="AllocatedSizeMB"; Expression={[math]::Round($_.AllocatedSize / 1MB, 2)}},
PhysicalSectorSize,
NumberOfPartitions,
@{Name="Manufacturer"; Expression={$_.Manufacturer.Trim()}},
FriendlyName
}},
@{Name="DriveCount"; Expression={$diskInfo.Count}},
@{Name="DriveInfo"; Expression={
$driveInfo | Select-Object DriveLetter,
FileSystemType,
DriveType,
@{Name="SizeMB"; Expression={[math]::Round($_.Size / 1MB, 2)}},
@{Name="SizeRemainingMB"; Expression={[math]::Round($_.SizeRemaining / 1MB, 2)}}
}}
$computerInfo | Out-Host
Write-Host 'MemoryInfo' -ForegroundColor Yellow
$computerInfo.MemoryInfo | Format-Table
Write-Host 'DiskInfo' -ForegroundColor Yellow
$computerInfo.DiskInfo | Format-Table
Write-Host 'DriveInfo' -ForegroundColor Yellow
$computerInfo.DriveInfo | Format-Table
Write-Host 'Get-HotFix' -ForegroundColor Yellow
Get-HotFix | Format-Table HotFixID,InstalledBy,@{Name="InstalledOn"; Expression={([DateTime]$_.InstalledOn).ToString("yyyy-MM-dd HH:mm:ssK")}} -AutoSize | Out-Host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment