Apr 172014
 

This script is to simply get all “client” computer names from Active Directory, then get WMI properties to ascertain whether a desk or laptop etc.

$Computers = Get-ADComputer -Filter {OperatingSystem -notlike “*Server*”} -Properties *
Foreach ($computer in $computers){
IF ($Computer.Description -eq $nul){
$testcomputer = $computer.name
IF (test-path \\$testcomputer\c$){
$Description = Get-ADComputer $computer -Properties *
$value = Get-WmiObject win32_systemenclosure -Computer $Computer.Name -ErrorAction SilentlyContinue
$ChassisType = $value.ChassisTypes
$update = Switch ($ChassisType)
{
“1” {“Other”}
“2” {“Virtual Machine”}
“3” {“Desktop”}
“4” {“Low Profile Desktop”}
“5” {“Pizza Box”}
“6” {“Mini Tower”}
“7” {“Tower”}
“8” {“Portable”}
“9” {“Chassis typecl is: $type – Laptop”}
“10” {“Notebook”}
“11” {“Handheld”}
“12” {“Docking Station”}
“13” {“All-in-One”}
“14” {“Sub-Notebook”}
“15” {“Space Saving”}
“16” {“Lunch Box”}
“17” {“Main System Chassis”}
“18” {“Expansion Chassis”}
“19” {“Sub-Chassis”}
“20” {“Bus Expansion Chassis”}
“21” {“Peripheral Chassis”}
“22” {“Storage Chassis”}
“23” {“Rack Mount Chassis”}
“24” {“Sealed-Case PC”}
default {“Unknown”}
}
If ($update -ne “Unknown”){
$output =  $Description.Name, $update
write-host $output -BackgroundColor DarkGreen -ForegroundColor WHITE
set-adcomputer $Description.Name -Description $update
}
else
{
Write-host $computer.name WMI FAILED -BackgroundColor BLUE -ForegroundColor WHITE
}

}
else
{
Write-host $computer.name Fail path test -BackgroundColor Red -ForegroundColor WHITE
}
}
else
{
Write-host $computer.name Description in already $Computer.Description
}
}

Leave a Reply