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
    $ServerWMI.Put()
}


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…

Thomas