MightyElectro
asked on
Script to Update computer's dscription in AD with Description set on local computer using GPO.
Our school district is wanting to redo all of our computer naming standards and are wanting to use the Description Field on the remote computer but we have found they do not update or sync with Active Directory and we want this to be updated regularly using a startup script or logon script. I have found a Script to update the description to show who was logoned on and at what time. But I am not a programer and cant find a way to pull the description and update that to active directory using the same script.
Here is some code to update the description to show the user who is loged on, is there a way of modifying this for my needs.
Here is some code to update the description to show the user who is loged on, is there a way of modifying this for my needs.
---A sample batch script.---------------------------
@echo off
setlocal
for /f "tokens=2 delims=:" %%a in ('ipconfig ^| findstr IP.*Address\.') do set ipAddr=%%a&goto :FOUNDIP
echo Couldn't find IP
goto :EOF
:FOUNDIP
set Machine=%computername%
set Description=%USERNAME% %ipAddr% %date%
for /f "delims=" %%a in ('dsquery computer -name "%Machine%"') do set MachineDN=%%a
dsmod computer %MachineDN% -desc "Logged in User: %Description%"
---Sameple VB Script.------------------------------
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName)
Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
strMessage = objUser.CN & " logged in at " & objComputer.CN & " " & Now & "."
'objUser.Description = strMessage
'objUser.SetInfo
objComputer.Description = strMessage
objComputer.SetInfo
ASKER
Hi henjoh09 Im not wanting to do either, what we have is a naming standard where we have our trt's or technology resource teachers update all the names of each computer to ComputerName =(location - %servicetag% ) and then in the description we are having them put in the ( location - room# - computer# - assettag# etc) but after doing this we have found the description doesnt update and sync to AD so I was hoping to find a script or modify a script to pull the description the TRT had entered in on the local machine and have that synced up to AD automatically eitehr on startup or when a user logson.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you wnat to rename the computername based on description or update the description field based on computername?