Using PowerShell to Identify Laptops with PowerShell Administration Scripts

PowerShell Identify Laptops – Step-by-step guide to Using PowerShell to Identify Laptops with PowerShell Administration Scripts, including configuration, deployment, troubleshooting and

Useful external reference: Microsoft Learn.

Function Get-IsLaptop {
    $isLaptop = $false
    if(Get-WmiObject -Class win32_systemenclosure | Where-Object { $_.chassistypes -eq 8 -or $_.chassistypes -eq 9 -or $_.chassistypes -eq 10 -or $_.chassistypes -eq 14 -or $_.chassistypes -eq 30}) { $isLaptop = $true }
    Add-Content $LogFile -value "isLaptop => $isLaptop"
    Return $isLaptop
}

# The first function does not correctly detect the HP Elite Dragonfly
function Test-IsLaptop {
    $isLaptop = $false
    $HardwareType = (Get-WmiObject -Class Win32_ComputerSystem -Property PCSystemType).PCSystemType
    # https://docs.microsoft.com/en-us/windows/win32/cimwin32prov/win32-computersystem
    # Mobile = 2
    if ($HardwareType -eq 2) { $isLaptop = $true }
    Add-Content $LogFile -value "isLaptop => $isLaptop"
    Return $isLaptop
}

PowerShell Identify Laptops Overview