Page 1 of 1 1
Topic Options
#138129 - 2005-04-19 11:10 AM @Wksta description field in ActiveDirectory
Wam Offline
Lurker

Registered: 2005-04-06
Posts: 2
Hi,

Is there a way to lookup the description field of a computer in ActiveDirectory? I am making a startup script (set by GPOs) for all domain computeraccounts and I would like to query the active directory for the description field. I tried @Comment but this only works for the logged in user, not for the computeraccount.

I feel this must be simple, I just can't figure out how to do it
Maybe someone already created an UDF for such things?

Regards,
Wam

Top
#138130 - 2005-04-19 12:34 PM Re: @Wksta description field in ActiveDirectory
Co Offline
MM club member
***

Registered: 2000-11-20
Posts: 1342
Loc: NL
Look at the Microsoft Script Center:

It is VBS but you can translate it to kix if you want....
Code:
 On Error Resume Next

Set objComputer = GetObject _
("LDAP://CN=atl-dc-01,CN=Computers,DC=fabrikam,DC=com")

objProperty = objComputer.Get("Location")
If IsNull(objProperty) Then
Wscript.Echo "The location has not been set."
Else
Wscript.Echo "Location: " & objProperty
objProperty = Null
End If

objProperty = objComputer.Get("Description")
If IsNull(objProperty) Then
Wscript.Echo "The description has not been set."
Else
Wscript.Echo "Description: " & objProperty
objProperty = Null
End If

_________________________
Co


Top
#138131 - 2005-04-19 03:01 PM Re: @Wksta description field in ActiveDirectory
Les Offline
KiX Master
*****

Registered: 2001-06-11
Posts: 12734
Loc: fortfrances.on.ca
I sync the "Description in AD to the "Server Comment" on the local box.
Here is a snippet of Code:

$ADProp = GetObject('LDAP://'+$RC[3])
$ADdesc = $ADProp.get('description')
If $Comment <> '' and $ADdesc <> $Comment
$ADProp.put('description',$comment)
$ADProp.setinfo
$ADProp = ''
$ADdesc = $Comment
endif
If $ADdesc <> '' and $Comment <> $ADdesc
$adsComputer = GetObject('WinNT://' + $Comp + '/LanmanServer')
$adsComputer.Description = $ADdesc
$adsComputer.SetInfo
$adsComputer = ''

_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.

Top
#138132 - 2005-04-19 03:53 PM Re: @Wksta description field in ActiveDirectory
Wam Offline
Lurker

Registered: 2005-04-06
Posts: 2
Hi Co, hi Les,

Great, never did anything with this kind of queries but your posts helped me a lot.
I came up with the following which is sufficient for what I want to do
Code:

Call 'TranslateName.udf'
$query = TranslateName(3,"",3,"@Domain\@WkSta$",1)
$ADprop = GetObject('LDAP://'+$query[0])
$ADdesc = $ADProp.get('description')
$ADprop = ''
? "AD description for '" + @WkSta + "' = " + $ADdesc



Thank you!
Wam

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 837 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.051 seconds in which 0.024 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org