(view source code of powershellcomputerclass.ps as plain text)
class Computer
{static [string]$Version = '1.00'
static [string]$Copyrights = 'Rob van der Woude'
static [string]$ProductPage = 'https://www.robvanderwoude.com/powershellcomputerclass.php'
static [string]$Help = @"
Computer class, Version {0}Make basic hardware infomation available in a classCopyrights {1} {2}{3}How to use:===========Create an instance of the Computer class using the following command:`$computer = [Computer]::New( )After gathering hardware information for a couple of seconds, `$computer will have the information available through its properties and methods:--------- --------- ------------------------------- ----------Property: DataType: Information on this computer's: WMI class:--------- --------- ------------------------------- ----------Name System.String computer nameIPAddress System.String local IP addressBIOS System.Object BIOS root/CIMV2/Win32_BIOSCDROM System.Object CD-ROM drive(s) root/CIMV2/Win32_CDROMDriveCPU System.Object processor(s) root/CIMV2/Win32_ProcessorHDD System.Object harddisk(s) root/Microsoft/Windows/Storage/MSFT_PhysicalDiskKeyboard System.Object keyboard(s) root/CIMV2/Win32_KeyboardMainBoard System.Object main board root/CIMV2/Win32_BaseBoardMemory System.Object memory root/CIMV2/Win32_PhysicalMemoryMonitor System.Object monitor(s) root/WMI/WmiMonitorIDMouse System.Object mouse (or mice) root/CIMV2/Win32_PointingDeviceNIC System.Object physical network adapter(s) root/CIMV2/Win32_NetworkAdapterPrinters System.Object physical local printer(s) root/CIMV2/Win32_PrinterSlots System.Object system slots root/CIMV2/Win32_SystemSlotSound System.Object sound card(s) root/CIMV2/Win32_SoundDeviceUSB System.Object USB controller(s) root/CIMV2/Win32_USBControllerVideo System.Object video card(s) root/CIMV2/Win32_VideoControllerWindows System.Object Windows version root/CIMV2/Win32_OperatingSystemWinSat System.Object WinSat system scores root/CIMV2/Win32_WinSAT--------- --------- ---------- ----------Property: DataType: Number of: WMI class:--------- --------- ---------- ----------_AGP System.Int32 AGP slots root/CIMV2/Win32_SystemSlot_AGP2X System.Int32 AGP2X slots root/CIMV2/Win32_SystemSlot_AGP4X System.Int32 AGP4X slots root/CIMV2/Win32_SystemSlot_AGP8X System.Int32 AGP8X slots root/CIMV2/Win32_SystemSlot_Cardbus System.Int32 Cardbus slots root/CIMV2/Win32_SystemSlot_CDROMs System.Int32 CD-ROM drives root/CIMV2/Win32_CDROMDrive_COMPorts System.Int32 serial ports root/CIMV2/Win32_SerialPort_EISA System.Int32 EISA slots root/CIMV2/Win32_SystemSlot_HDDs System.Int32 harddisk drives root/Microsoft/Windows/Storage/MSFT_PhysicalDisk_ISA System.Int32 ISA slots root/CIMV2/Win32_SystemSlot_LPTPorts System.Int32 parallel ports root/CIMV2/Win32_ParallelPort_MemoryGB System.Int32 GigaBytes of memory root/CIMV2/Win32_PhysicalMemory_MemoryModules System.Int32 memory modules root/CIMV2/Win32_PhysicalMemory_MemorySockets System.Int32 memory sockets root/CIMV2/Win32_PhysicalMemoryArray_Monitors System.Int32 monitors root/WMI/WmiMonitorID_PCI System.Int32 PCI slots root/CIMV2/Win32_SystemSlot_PCIE System.Int32 PCI-E slots root/CIMV2/Win32_SystemSlot_PCIX System.Int32 PCI-X slots root/CIMV2/Win32_SystemSlot_PCMCIA System.Int32 PCMCIA slots root/CIMV2/Win32_SystemSlot_USB2 System.Int32 USB controllers (except USB 3) root/CIMV2/Win32_USBController_USB3 System.Int32 USB 3 controllers root/CIMV2/Win32_USBController_VESA System.Int32 VESA slots root/CIMV2/Win32_SystemSlotStatic Members:===============----------------------- ------------ ------Properties and Methods: Description: Value:----------------------- ------------ ------[Computer]::Version This class' version {0}[Computer]::Copyrights Author's name {2}[Computer]::ProductPage This class' webpage {3}[Computer]::Help This help text[Computer]::OpenProductPage( ) Open this class' webpage[Computer]::New( ) Create new instance of this class"@ -f [Computer]::Version, [char]0x00A9, [Computer]::Copyrights, [Computer]::ProductPage
static [void]OpenProductPage( )
{Start-Process -FilePath $( [Computer]::ProductPage )
}[string]$Name = $Env:ComputerName
[string]$IPAddress = $( [System.Net.Dns]::Resolve( $Env:ComputerName ).AddressList.IPAddressToString )
[object]$BIOS
[object]$CDROM
[object]$CPU
[object]$HDD
[object]$Keyboard
[object]$MainBoard
[object]$Memory
[object]$Monitor
[object]$Mouse
[object]$NIC
[object]$Printers
[object]$Slots
[object]$Sound
[object]$USB
[object]$Video
[object]$Windows
[object]$WinSat
[int]$_AGP
[int]$_AGP2X
[int]$_AGP4X
[int]$_AGP8X
[int]$_Cardbus
[int]$_CDROMs
[int]$_COMPorts
[int]$_EISA
[int]$_HDDs
[int]$_ISA
[int]$_LPTPorts
[int]$_MemoryGB
[int]$_MemoryModules
[int]$_MemorySockets
[int]$_Monitors
[int]$_PCI
[int]$_PCIE
[int]$_PCIX
[int]$_PCMCIA
[int]$_USB2
[int]$_USB3
[int]$_VESA
Computer( )
{$this.BIOS = $( Get-CimInstance -ClassName Win32_BIOS )
$this.CDROM = $( Get-CimInstance -ClassName Win32_CDROMDrive | Where-Object { $_.Name -notmatch 'virtual' } )
$this.CPU = $( Get-CimInstance -ClassName Win32_Processor )
$this.HDD = $( Get-CimInstance -ClassName MSFT_PhysicalDisk -Namespace root/Microsoft/Windows/Storage )
$this.Keyboard = $( Get-CimInstance -ClassName Win32_Keyboard )
$this.MainBoard = $( Get-CimInstance -ClassName Win32_BaseBoard )
$this.Memory = $( Get-CimInstance -ClassName Win32_PhysicalMemory )
$this.Monitor = $( Get-CimInstance -ClassName WmiMonitorID -Namespace root/WMI )
$this.Mouse = $( Get-CimInstance -Classname Win32_PointingDevice )
$this.NIC = $( Get-CimInstance -ClassName Win32_NetworkAdapter | Where-Object { $_.Speed -gt 0 } ) # physical adapters only
$this.Printers = $( Get-CimInstance -ClassName Win32_Printer | Where-Object { $_.PrintProcessor -ne 'winprint' -and $_.Local } ) # physical local printers only
$this.Slots = $( Get-CimInstance -ClassName Win32_SystemSlot )
$this.Sound = $( Get-CimInstance -ClassName Win32_SoundDevice | Where-Object { $_.Manufacturer -ne 'Microsoft' } ) # physical soundcards only
$this.USB = $( Get-CimInstance -ClassName Win32_USBController )
$this.Video = $( Get-CimInstance -ClassName Win32_VideoController )
$this.Windows = $( Get-CimInstance -ClassName Win32_OperatingSystem )
$this.WinSat = $( Get-CimInstance -ClassName Win32_WinSAT -Filter "TimeTaken='MostRecentAssessment'" )
$this._AGP = $( $this.Slots | Where-Object { $_.ConnectorType -eq 73 } | Measure-Object ).Count
$this._AGP2X = $( $this.Slots | Where-Object { $_.ConnectorType -eq 81 } | Measure-Object ).Count
$this._AGP4X = $( $this.Slots | Where-Object { $_.ConnectorType -eq 82 } | Measure-Object ).Count
$this._AGP8X = $( $this.Slots | Where-Object { $_.ConnectorType -eq 99 } | Measure-Object ).Count
$this._Cardbus = $( $this.Slots | Where-Object { $_.ConnectorType -eq 52 } | Measure-Object ).Count
$this._CDROMs = $( $this.CDROM | Measure-Object ).Count
$this._COMPorts = $( Get-CimInstance -ClassName Win32_SerialPort | Measure-Object ).Count
$this._EISA = $( $this.Slots | Where-Object { $_.ConnectorType -eq 45 } | Measure-Object ).Count
$this._HDDs = $( $this.HDD | Measure-Object ).Count
$this._ISA = $( $this.Slots | Where-Object { $_.ConnectorType -eq 44 } | Measure-Object ).Count
$this._LPTPorts = $( Get-CimInstance -ClassName Win32_ParallelPort | Measure-Object ).Count
$_Memory = 0
$this.Memory.Capacity | ForEach-Object { $_Memory += $_ }
$this._MemoryGB = $( $_Memory / 1GB )
$this._MemoryModules = $( $this.Memory | Measure-Object ).Count
$this._MemorySockets = $( Get-CimInstance -ClassName Win32_PhysicalMemoryArray ).MemoryDevices
$this._Monitors = $( $this.Monitor | Measure-Object ).Count
$this._PCMCIA = $( $this.Slots | Where-Object { $_.ConnectorType -gt 46 -and $_.ConnectorType -lt 51 } | Measure-Object ).Count
$this._PCI = $( $this.Slots | Where-Object { $_.ConnectorType -eq 43 -or $_.ConnectorType -eq 80 } | Measure-Object ).Count
$this._PCIE = $( $this.Slots | Where-Object { $_.ConnectorType -eq 100 } | Measure-Object ).Count
$this._PCIX = $( $this.Slots | Where-Object { $_.ConnectorType -eq 88 } | Measure-Object ).Count
$this._USB3 = $( $this.USB | Where-Object { $_.Name -match 'USB ?3' } | Measure-Object ).Count # not very reliable, as this relies on the description
$this._USB2 = $( $this.USB | Measure-Object ).Count - $this._USB3 # total number of USB controllers - number of USB 3 controllers
$this._VESA = $( $this.Slots | Where-Object { $_.ConnectorType -eq 46 } | Measure-Object ).Count
}}page last modified: 2025-10-11; loaded in 0.0114 seconds