Skip to content

Instantly share code, notes, and snippets.

@dpo007
Created August 29, 2022 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dpo007/b1e0c2469e321768aa982ec097f8e5ce to your computer and use it in GitHub Desktop.
Save dpo007/b1e0c2469e321768aa982ec097f8e5ce to your computer and use it in GitHub Desktop.
PowerShell :: Detect if local computer is portable or not, based on WMI/ChassisType.
$isPortable = $false
$chassisType = (Get-CimInstance -Query "Select * from Win32_SystemEnclosure").ChassisTypes[0]
switch ($chassisType) {
# Case 8 "Portable"
# Case 9 "Laptop"
# Case 10 "Notebook"
# Case 11 "Handheld"
# Case 14 "Sub-Notebook"
{$_ -in 8, 9, 10, 11, 14} { $isPortable = $true }
}
$isPortable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment