Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Active Directory - Computer Description Field

Status
Not open for further replies.

thefourthwall

IS-IT--Management
Feb 26, 2002
387
US
Hello,

I am not sure if this should post to the W2K3 Server forum or this one; if I've posted incorrectly, please advise.

The question I was asked is: can the "Description" field for a computer object in our Active Directory domain be populated by the "Description" field found on the "Computer Name" tab of an XP client's System Properties sheet?

Maybe a better way of asking: is there any linkage between the client's "Description" field and the workstation object's "Description" field in Active Directory Users & Computers ?

thanks in advance,

-thefourthwall
 
That's a good question. I don't see a link. I noticed when I changed the PC description at the computer, my change appeared in the Network Neighborhood browser but not AD.

I think it would be easy to script something to match the local description to AD, or even other fun stuff.

See this Scripting Guys article:
 
Protovision, thanks for your reply. I noticed the same thing re: Network Neighborhood (My Network Places, etc.).

Found yesterday that it can be scripted, and it appears to be necessary to run from the server console, so will explore that today.

Thank you.
 
I do something similar but prefer setting the description from AD but do provide the ability to set it on the local workstation (in my case AD will override the one set on the local machine). I also like to show the description and the machines serial number (Dell Service Tag in my case) to the user when they hit CTRL-ALT-DEL.

Here's what I use via Group Policy system script:


option explicit
On error resume next

Dim objShell, objADSysInfo
Set objShell = CreateObject("WScript.Shell")
Set objADSysInfo = CreateObject("ADSystemInfo")

'These are the registry keys for the description broadcast in Network Neighborhood
'and for the caption/title bar shown when hitting ctrl-alt-del
Dim strRegSrvComment, strRegWelcome, strLocalDescription
strRegSrvComment = "HKLM\System\CurrentControlSet\Services\lanmanserver\parameters\SrvComment"
strRegWelcome = "HKLM\Software\Microsoft\Windows NT\CurrentVersion\WinLogon\Welcome"
strLocalDescription = objShell.RegRead(strRegSrvComment)

'Get the Active Directory Distinguished name for the current computer
Dim strADComputer, strLocalComputer
strADComputer = objADSysInfo.ComputerName
strLocalComputer = objShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
objShell.LogEvent 0,"Starting CompDescription Sub: " & strADComputer & " " & strLocalComputer

'Get the Active Directory Object for the current computer
Dim objADComputer, strADDescription
Set objADComputer = GetObject("LDAP://" & strADComputer)
strADDescription = objADComputer.Description

'Get the Local Object for the current computer
Dim objLocalComputer, colEncl
Set objLocalComputer = GetObject("winmgmts:\\" & strLocalComputer & "\root\cimv2")
Set colEncl = objLocalComputer.ExecQuery("Select * from Win32_SystemEnclosure",,48)

'Get the system serial number must be less than seven chars (Dell is usually 7 exactly unless really old then its 5)
Dim objEncl
For Each objEncl in colEncl
If Len(objItem.SerialNumber) <= 7 Then
strSerialNumber = objItem.SerialNumber
End If
Next

'Compare the Active Directory description with the Local computer description
If LCase(strADDescription) <> LCase(strLocalDescription) Then

'if the descriptions don't match we've got a change.
objShell.LogEvent 0,"AD and Local description do not match" & strADDescription & " " & strLocalDescription

If strADDescription <> "" Then
objShell.LogEvent 0,"Setting Local Description to the one in AD: " & strADDescription
objShell.Run "net config server /srvcomment:" & Chr(34) & strADDescription & Chr(34)
strDescription = strADDescription
Else
objShell.LogEvent 0,"Setting AD Description to the one from the system: " & strLocalDescription
objADComputer.Put "description",strLocalDescription
objADComputer.SetInfo
strDescripton = strLocalDescription
End If

'Since we have a change in Description lets reflect that on the CTRL-ALT-DEL screen so the user
'can see our hard work which will be the logon caption bar text:
'Windows Security | ComputerName | Description ------if the serial number is in the computername
'Windows Security | Computername | Serial Number | Description ------if the serial isn't in the compname
If InStr(strLocalComputer,strSerialNumber) = 0 Then
objShell.RegWrite strRegWelcome,"| " & strLocalComputer & " | " & strSerialNumber & " | " & strDescription
Else
objShell.RegWrite strRegWelcome,"| " & strLocalComputer & " | " & strDescription
End If

End If


'cleanup
Set objADComputer = Nothing
Set objLocalComputer = Nothing
Set objEncl = Nothing
Set objShell = Nothing
Set objADSysInfo = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top