I’m a ConfigMgr admin by day. I have to manage thousands of workstations; some desktops and some thin clients. Thin clients and desktops are two different device types and must be handled different. When running Powershell scripts against these workstations I always have the need to tell if I’m working with a thin client or a desktop. One of the big reasons is to specify different ConfigMgr client install settings such as cache size, compressed installation, etc. This function is the one I use all the time.
This function takes one argument; a computer name. If no computer name is specified it’ll default to localhost. It then attempts a WMI query against the device to find the Model attribute. In my environment I define a thin client as anything with ‘hp t*’ in the model name that’s not a ‘hp touchsmart’ model. Your thin clients may differ here in model. If it matches ‘hp t*’ but is not a HP touch smart device I define it as a thin client. If, for some reason, a WMI query won’t work I grab the attributes from the remote PC’s explorer exe to see if it’s compressed or not. In my environment, all thin clients have a compressed hard drive and no desktops do. I consider this my fallback attempt.
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 "\$ComputerNameadmin$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 } } }
Download this script on poshcode.org
The post How to Tell a Thin Client From a Desktop with Powershell appeared first on Adam, the Automator.