I need to scan the domain for only laptops

Joshua Fisher 0 Reputation points
2023-12-12T20:31:17.4633333+00:00

I need to write a script that scans the domain for all computers, and then pulls bitlocker status on ONLY the laptops.

Current code is:

Get-ADComputer -Filter * -SearchBase "DC=my,DC=domain,DC=com"| foreach{
  $HardwareType = (Get-WmiObject -Class Win32_ComputerSystem -Property PCSystemType).PCSystemType
  if ($Hardwaretype -eq 2) {
   manage-bde -status -cn $_.Name c: |
   where {$_ -match '(Computer Name|Protection Status|Conversion Status)'  }
    } 
    
} 


So far, its pulling everything.

PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,971 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-12-13T07:22:22.2466667+00:00

    I need to scan the domain for only laptops

    Hello,

    You can try to use the command below to detect laptop or server. Shows battery status , if true then the machine is a laptop.

    Get-WmiObject -Class win32_battery -ComputerName $computer
    

    Any update, please let me know.

    Best Regards,

    Ian Xue


    If the Answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.