?
Solved

Adding information to description field of computer objects in Active Directory

Posted on 2013-02-06
7
Medium Priority
?
339 Views
Last Modified: 2013-03-16
Hello,

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!
0
Comment
Question by:jacksonwsa
7 Comments
 
LVL 17

Expert Comment

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

http://technet.microsoft.com/en-us/scriptcenter/dd939958.aspx

This should help you get started..

HTH,

Kent
0
 
LVL 16

Expert Comment

by:Chris H
ID: 38862575
Do you want powershell, vbs or batch file?
0
 
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, ",", ".")
Next

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

' 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 
objComputer.SetInfo

Open in new window

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

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

Author Comment

by:jacksonwsa
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)
  {
   if([string]::isNullOrEmpty($user.description))
    {
      "modifying $($user.name)"
      Set-ADUser -Identity $user.distinguishedName -Description "added via script"
      $i++
    }
 }
"modified $i users"
0
 

Accepted Solution

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

Author Closing Comment

by:jacksonwsa
ID: 38991470
Not resolved
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By default Outlook 2016 displays only one time zone in the Calendar. The following article explains how to display two time zones in one calendar view.
Most folks would know the basics of how Dropbox works, so that’s not the purpose of this article. Security is what it’s all about, so here I’ll share how I choose to secure my Dropbox Account and the Data it contains.
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses

850 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