Public/Hardware/Get-ChassisInfo.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-ChassisInfo { <# .SYNOPSIS Retrieves and displays chassis information for the current system. .DESCRIPTION This function collects various details about the system's chassis, including the type, manufacturer, and serial number. It also gathers information about the computer system and calculates the age of the CPU. .PARAMETER ChassisInfo The collection of chassis information retrieved from the Win32_SystemEnclosure class. .PARAMETER ComputerInfo The collection of computer system information retrieved from the Win32_ComputerSystem class. .EXAMPLE Get-ChassisInfo This command retrieves and displays the chassis information for the current system, including the type, manufacturer, and age of the CPU. .NOTES This function uses CIM instances to gather system information and may require appropriate permissions to execute. #> [CmdletBinding()] PARAM ( ) $ChassisInfo = Get-CIMInstance Win32_SystemEnclosure -ErrorAction SilentlyContinue $ComputerInfo = Get-CIMInstance Win32_ComputerSystem Switch ($ChassisInfo.ChassisTypes) { "1" { $EnclosureType = "Other" } "2" { $EnclosureType = "Unknown" } "3" { $EnclosureType = "Desktop" } "4" { $EnclosureType = "Low Profile Desktop" } "5" { $EnclosureType = "Pizza Box" } "6" { $EnclosureType = "Mini Tower" } "7" { $EnclosureType = "Tower" } "8" { $EnclosureType = "Portable" } "9" { $EnclosureType = "Laptop" } "10" { $EnclosureType = "Notebook" } "11" { $EnclosureType = "Hand Held" } "12" { $EnclosureType = "Docking Station" } "13" { $EnclosureType = "All in One" } "14" { $EnclosureType = "Sub Notebook" } "15" { $EnclosureType = "Space-Saving" } "16" { $EnclosureType = "Lunch Box" } "17" { $EnclosureType = "Main System Chassis" } "18" { $EnclosureType = "Expansion Chassis" } "19" { $EnclosureType = "SubChassis" } "20" { $EnclosureType = "Bus Expansion Chassis" } "21" { $EnclosureType = "Peripheral Chassis" } "22" { $EnclosureType = "Storage Chassis" } "23" { $EnclosureType = "Rack Mount Chassis" } "24" { $EnclosureType = "Sealed-Case PC" } "30" { $EnclosureType = "Tablet" } "31" { $EnclosureType = "Convertible" } "32" { $EnclosureType = "Detachable" } default { $EnclosureType = "Unknown" } } $Age = (Get-CPUInfo).YearsOld $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ Hostname = $ComputerInfo.Name Model = $ComputerInfo.Model Manufacturer = $ChassisInfo.Manufacturer SerialNumber = $ChassisInfo.SerialNumber ChassisType = $EnclosureType YearsOld = $Age } RETURN $Results | Select-Object Hostname, Model, Manufacturer, ChassisType, SerialNumber, YearsOld } |