Adding information to description field of computer objects in Active Directory

Posted on 2013-02-06
Medium Priority
Last Modified: 2013-03-16

I'm looking for a script that will add information to the description field for a list of servers. If it would work with a servers.txt file that I could put a list of server in that would be ideal or something along those lines. I'm looking to add "Virtual" to our "Servers" OU in the description field to like 800 servers so that we can query against that to find all of our vm's. Thanks!
Question by:jacksonwsa
LVL 17

Expert Comment

by:Kent Dyer
ID: 38862569
First, I would start with the ADSI Script-o-matic from Microsoft..


This should help you get started..


LVL 16

Expert Comment

by:Chris H
ID: 38862575
Do you want powershell, vbs or batch file?
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38863933
Here is something to start with, I use it as a user login script. .VBS
Set WshNetwork = WScript.CreateObject("WScript.Network")
Set objWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")

' get service tag and computer manufacturer
For Each objSMBIOS in objWMI.ExecQuery("Select * from Win32_SystemEnclosure")
serviceTag = replace(objSMBIOS.SerialNumber, ",", ".")
manufacturer = replace(objSMBIOS.Manufacturer, ",", ".")

' get computer model
For Each objComputer in objWMI.ExecQuery("Select * from Win32_ComputerSystem")
model = trim(replace(objComputer.Model, ",", "."))

' get computer object in AD
Set objSysInfo = CreateObject("ADSystemInfo")
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)

' build up description field data and save into computer object
objComputer.Description = WshNetwork.UserName & " - Computer Manufacturer: " & manufacturer & " - Model: " & model & " - Serial Number: " & " " & serviceTag & " " & Now 

Open in new window

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.


Author Comment

ID: 38866369
Powershell preferably but anything would work. I just need something simple if possible.

Author Comment

ID: 38883111
What about this. I found this online and would only need to change it to work against computer objects rather than a user, and a .txt file with a list of servers (get-content) in some form or fashion..

Import-Module ActiveDirectory
 $users = $i = $null
 $users = Get-ADUser -SearchBase "ou=testou,dc=nwtraders,dc=com" -filter * `
  -property description
 ForEach($user in $users)
      "modifying $($user.name)"
      Set-ADUser -Identity $user.distinguishedName -Description "added via script"
"modified $i users"

Accepted Solution

jacksonwsa earned 0 total points
ID: 38976232
This was not resolved

Author Closing Comment

ID: 38991470
Not resolved

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

This is an article on how to answer questions, earn points and become an expert.
The Windows Firewall provides an important layer of protection and a rich interface to configure it. Unfortunately, it lacks item level filtering. This article details my process of implementing firewall-as-code to reduce GPO bloat.
This Micro Tutorial will give you a basic overview of Windows DVD Burner through its features and interface. This will be demonstrated using Windows 7 operating system.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question