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
}

0 Comments

Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.