Friday, January 21, 2011

Update Computer Description from Active Directory

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.

$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

This script simply queries AD for all the servers,gets the computer name and description. It then connects to the server and updates the description. Pretty straight forward and simple…


1 comment:

  1. Need to add "-Properties Description" in Server 2008R2, otherwise the AD Description field does not appear and nothing gets updated:

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

    Otherwise great script.