Created
March 5, 2026 18:36
-
-
Save fdcastel/fe283dae8dae375292f469ac138b4e7f to your computer and use it in GitHub Desktop.
Retrieve computer information using Get-CimInstance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $result = [ordered]@{ | |
| ComputerSystem = Get-CimInstance CIM_ComputerSystem | Select-Object -Property ` | |
| 'Name', | |
| 'Description', | |
| 'PrimaryOwnerName', | |
| 'ChassisSKUNumber', | |
| 'CurrentTimeZone', | |
| 'DaylightInEffect', | |
| 'DNSHostName', | |
| 'EnableDaylightSavingsTime', | |
| 'HypervisorPresent', | |
| 'Manufacturer', | |
| 'Model', | |
| 'NetworkServerModeEnabled', | |
| 'NumberOfLogicalProcessors', | |
| 'SystemFamily', | |
| 'SystemSKUNumber', | |
| 'SystemType', | |
| 'TotalPhysicalMemory' | |
| OperatingSystem = Get-CimInstance CIM_OperatingSystem | Select-Object -Property ` | |
| 'Caption', | |
| 'InstallDate', | |
| 'LastBootUpTime', | |
| 'LocalDateTime', | |
| 'Version' | |
| Processor = Get-CimInstance CIM_Processor | Select-Object -Property ` | |
| 'L2CacheSize', | |
| 'SocketDesignation', | |
| 'Description', | |
| 'Name', | |
| 'L3CacheSize', | |
| 'Manufacturer', | |
| 'NumberOfCores', | |
| 'NumberOfEnabledCore', | |
| 'NumberOfLogicalProcessors', | |
| 'ProcessorId', | |
| 'ThreadCount' | |
| Card = Get-CimInstance CIM_Card | Select-Object -Property ` | |
| 'Manufacturer', | |
| 'SerialNumber', | |
| 'Version', | |
| 'Product' | |
| PhysicalMemory = Get-CimInstance CIM_PhysicalMemory | Sort-Object -Property DeviceLocator | Select-Object -Property ` | |
| 'Manufacturer', | |
| 'PartNumber', | |
| 'SerialNumber', | |
| 'Tag', | |
| 'FormFactor', | |
| 'Capacity', | |
| 'DataWidth', | |
| 'InterleavePosition', | |
| 'Speed', | |
| 'ConfiguredClockSpeed', | |
| 'ConfiguredVoltage', | |
| 'DeviceLocator', | |
| 'InterleaveDataDepth' | |
| PhysicalMemoryArray = Get-CimInstance Win32_PhysicalMemoryArray | Select-Object -Property ` | |
| 'MaxCapacity', | |
| 'MemoryDevices' | |
| DiskDrive = Get-CimInstance CIM_DiskDrive | Sort-Object -Property Index | Select-Object -Property ` | |
| 'BytesPerSector', | |
| 'Index', | |
| 'Size', | |
| 'FirmwareRevision', | |
| 'Model', | |
| 'SerialNumber' | |
| # Ignore Remote Desktop Connection controller | |
| VideoController = Get-CimInstance CIM_VideoController | Where-Object { $_.Description -notlike '*Remote*' } | Select-Object -Property ` | |
| 'Description', | |
| 'CurrentRefreshRate', | |
| 'VideoProcessor', | |
| 'AdapterRAM', | |
| 'DriverDate', | |
| 'DriverVersion', | |
| 'VideoModeDescription' | |
| } | |
| # Physical adapters only | |
| Get-CimInstance Win32_NetworkAdapter | | |
| Where-Object { $_.PNPDeviceID -like 'PCI\*' } | | |
| Sort-Object -Property 'DeviceID' | | |
| Foreach-Object -Begin { $i = 0 } -Process { | |
| $result["NetworkAdapter$i"] = $_ | Select-Object -Property ` | |
| 'Name', | |
| 'AdapterType', | |
| 'InterfaceIndex', | |
| 'MACAddress', | |
| 'Manufacturer', | |
| 'NetConnectionID', | |
| 'NetConnectionStatus', | |
| 'NetEnabled', | |
| 'ServiceName', | |
| 'TimeOfLastReset' | |
| $netAdapter = $_ | |
| $result["NetworkAdapterConfiguration$i"] = Get-CimInstance Win32_NetworkAdapterConfiguration | Where-Object { $_.IPEnabled -and $_.MACAddress -eq $netAdapter.MACAddress } | Select-Object -Property ` | |
| 'DHCPLeaseExpires', | |
| 'Description', | |
| 'DHCPEnabled', | |
| 'DHCPLeaseObtained', | |
| 'DHCPServer', | |
| 'DNSDomain', | |
| 'DNSDomainSuffixSearchOrder', | |
| 'DNSEnabledForWINSResolution', | |
| 'DNSHostName', | |
| 'DNSServerSearchOrder', | |
| 'DomainDNSRegistrationEnabled', | |
| 'FullDNSRegistrationEnabled', | |
| 'IPAddress', | |
| 'IPConnectionMetric', | |
| 'DefaultIPGateway', | |
| 'IPSubnet', | |
| 'MACAddress' | |
| $i++ | |
| } | |
| # Flatten | |
| $result.Keys | Foreach-Object -Begin { $flattenedResult = [ordered]@{} } -Process { | |
| $key = $_ | |
| if ($result[$key]) { | |
| $result[$key] | Get-Member -MemberType NoteProperty | ForEach-Object { | |
| $flattenedResult["$($key).$($_.Name)"] = $result[$key].$($_.Name) | |
| } | |
| } | |
| } | |
| $flattenedResult |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment