PoshCode Archive  Artifact [ceec2873f5]

Artifact ceec2873f578166f169689a1baa113cd962fd0e89377ed8ced7d8d315f772117:

  • File Get-DeviceChassis.ps1 — part of check-in [99f4d20439] at 2018-06-10 13:44:31 on branch trunk — A simple function that returns where a remote Windows device is a thin client or a desktop. (user: Adam Bertram size: 1578)

# encoding: ascii
# api: powershell
# title: Get-DeviceChassis
# description: A simple function that returns where a remote Windows device is a thin client or a desktop.
# version: 0.1
# type: function
# author: Adam Bertram
# license: CC0
# function: Get-DeviceChassis
# x-poshcode-id: 4683
# x-archived: 2013-12-13T12:49:51
# x-published: 2013-12-09T18:59:00
#
#
Function Get-DeviceChassis () {
    [CmdletBinding()]
    Param($ComputerName = 'localhost')
 
    PROCESS { 
        $Output = New-Object PsObject -property @{ComputerName = $ComputerName;Chassis=''}
        try {
            $Model = (Get-WmiObject -Query "SELECT Model FROM Win32_ComputerSystem" -ComputerName $ComputerName).Model;
                if (($Model -like 'hp t*') -and ($Model -notlike 'hp touchsmart*')) {
                    Write-Verbose "Found chassis to be thin client via WMI";
                    $Output.Chassis = 'Thin Client'
	    	} else {
                    Write-Verbose "Found chassis to be desktop via WMI";
                    $Output.Chassis = 'Desktop'
	    	}##endif
        } catch {
            if ((Get-Item "\\$ComputerName\admin$\explorer.exe").Attributes -match 'Compressed') {
                Write-Verbose "Found chassis to be thin client via compressed files";
                $Output.Chassis = 'Thin Client'
            } else {
                Write-Verbose "Found chassis to be desktop via compressed files";
                $Output.Chassis = 'Desktop'
            }
        } finally {
            $Output
        }
    }
}