Update Computer Description from Active Directory

Update Computer Description from Active Directory

PowerShell script to synchronize computer descriptions from Active Directory to the local computer system properties using WMI.

We try and keep everything in our domain synchronized, however it’s not always easy when the data is kept in three or more independent locations. I created this script a few years ago with the Quest cmdlets but figured since I can do it natively with the AD cmdlets I would update it and repost it.

The Problem

Computer descriptions are often maintained in Active Directory but not synchronized to the actual computer’s system properties. This creates inconsistency when viewing system information locally versus in AD.

The Solution

This script queries AD for all servers, gets the computer name and description, then connects to each server and updates the local description to match AD.

$Servers = Get-ADComputer -Filter {OperatingSystem -like "*Server*"} | Select-Object Name, Description | Sort-Object Name

foreach ($Server in $Servers) {
    $ServerWMI = Get-WmiObject -class win32_operatingsystem -computername $Server.Name
    $ServerWMI.Description = $Server.Description
    $ServerWMI.Put()
}

How it Works

  1. Query AD: Gets all computers with “Server” in the operating system name
  2. Iterate: Loops through each server found
  3. Connect via WMI: Uses WMI to connect to the remote computer’s operating system object
  4. Update: Sets the local description to match the AD description
  5. Save: Commits the change using the Put() method

This script ensures that the computer description shown in local system properties matches what’s documented in Active Directory, providing consistency across your infrastructure.

Pretty straightforward and simple…