PoshCode Archive  Artifact [189b4f8c54]

Artifact 189b4f8c544c67c25d6deed0953cd9a3195146293359267e39f2cc370cde20ca:

  • File Chassis-Type.ps1 — part of check-in [44ffe95c83] at 2018-06-10 13:18:28 on branch trunk — Ever wonder what kind of chassis your computer thinks it’s running on? Have a need to know if you’re RDP’d into a physical or virtual system? This script can probably answer the question for you. This script was adapted to PowerShell from a VBScript I’ve had for a while. It uses WMI to determine the Chassis type and translates the reported numerical code into decipherable text. – Thought i would rewrite this code using the switch function rather than elseif. Easier to read and less code to write. (user: AlphaSun size: 2292)

# encoding: ascii
# api: powershell
# title: Chassis Type
# description: Ever wonder what kind of chassis your computer thinks it’s running on? Have a need to know if you’re RDP’d into a physical or virtual system? This script can probably answer the question for you. This script was adapted to PowerShell from a VBScript I’ve had for a while. It uses WMI to determine the Chassis type and translates the reported numerical code into decipherable text. – Thought i would rewrite this code using the switch function rather than elseif. Easier to read and less code to write.
# version: 0.1
# type: class
# author: AlphaSun
# license: CC0
# x-poshcode-id: 2996
# x-derived-from-id: 3668
# x-archived: 2016-06-09T00:21:38
# x-published: 2012-10-09T18:52:00
#
#
$system = Get-WMIObject -class Win32_systemenclosure
$type = $system.chassistypes

Switch ($Type)
    {
        "1" {"Chassis type is: $Type - Other"}
        "2" {"Chassis type is: $type - Virtual Machine"}
        "3" {"Chassis type is: $type - Desktop"}
        "4" {"Chassis type is: $type - Low Profile Desktop"}
        "5" {"Chassis type is: $type - Pizza Box"}
        "6" {"Chassis type is: $type - Mini Tower"}
        "7" {"Chassis type is: $type - Tower"}
        "8" {"Chassis type is: $type - Portable"}
        "9" {"Chassis type is: $type - Laptop"}
        "10" {"Chassis type is: $type - Notebook"}
        "11" {"Chassis type is: $type - Handheld"}
        "12" {"Chassis type is: $type - Docking Station"}
        "13" {"Chassis type is: $type - All-in-One"}
        "14" {"Chassis type is: $type - Sub-Notebook"}
        "15" {"Chassis type is: $type - Space Saving"}
        "16" {"Chassis type is: $type - Lunch Box"}
        "17" {"Chassis type is: $type - Main System Chassis"}
        "18" {"Chassis type is: $type - Expansion Chassis"}
        "19" {"Chassis type is: $type - Sub-Chassis"}
        "20" {"Chassis type is: $type - Bus Expansion Chassis"}
        "21" {"Chassis type is: $type - Peripheral Chassis"}
        "22" {"Chassis type is: $type - Storage Chassis"}
        "23" {"Chassis type is: $type - Rack Mount Chassis"}
        "24" {"Chassis type is: $type - Sealed-Case PC"}
        Default {"Chassis type is: $type - Unknown"}
     }