Page 1 of 1 1
Topic Options
#148457 - 2005-09-23 08:57 PM New Macros - @Desc and @ADDesc
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Low priority, but I'd like to see two new macros that read Description fields.

@Desc - Reads the Computer Description field under My Computer>Properties>Computer Name

@ADDesc - Reads the Description field of the computer object in AD

Not sure of M$ logic of not syncronizing these when a computer is part of a domain.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#148458 - 2005-09-26 11:20 AM Re: New Macros - @Desc and @ADDesc
Richard H. Administrator Offline
Administrator
*****

Registered: 2000-01-24
Posts: 4946
Loc: Leatherhead, Surrey, UK
Quote:

@Desc - Reads the Computer Description field under My Computer>Properties>Computer Name




Can you not get this from the registry:
Code:
$sComputerDescription=ReadValue("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters","srvcomment")
"Computer Description: '"+$sComputerDescription+"'"+@CRLF



Quote:

@ADDesc - Reads the Description field of the computer object in AD




IMO we are moving away from hard-coding access to this sort of information and towards using the standard providers. Why would you pick on one attribute of the object and present it as a macro?

The information is very easy to retrieve from the object, and using the standard providers means that future extensions will also be available.

For example, getting the computer description is as simple as:
Code:
$objSys = CreateObject("ADSystemInfo")
"Computer description='"+GetObject("LDAP://"+$objSys.ComputerName).Description+"'"+@CRLF



I don't think it is a terrible idea, just a bit inflexible and redundant when the data is readily available using existing functionality.

Quote:

Not sure of M$ logic of not syncronizing these when a computer is part of a domain.




Yup, it's a puzzler.

Top
#148459 - 2005-09-26 06:21 PM Re: New Macros - @Desc and @ADDesc
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Quote:

Can you not get this from the registry:



Yes, as is the case with 85% of the macros.

Quote:

Why would you pick on one attribute of the object and present it as a macro?



Because this is the only AD attribute that I know of that is duplicative to the workstation. I've started populating this field as such [ASSET_TAG] : [BUILDING] : [ROOM#] : [POC] : [DESC]

In AD I can see all of the info in ADUC. I want to replicate it (maybe once monthly) to the workstation so my asset mgmt software can pull it from the local machine w/o inflicting more network overhead and also not have to be attached to the network. Also I can call a user and easily request this info or look it up on their PC in the field. There's a lot of potential including a large potential source of confusion b/c the field are duplicative.

Quote:

The information is very easy to retrieve from the object, and using the standard providers means that future extensions will also be available.

For example, getting the computer description is as simple as:
Code:
$objSys = CreateObject("ADSystemInfo")
"Computer description='"+GetObject("LDAP://"+$objSys.ComputerName).Description+"'"+@CRLF





Again, as is the case with most macros. They're there b/c they make writing code easier. Surely, it's easier to type @ADDesc. And BTW, to make a point, you neglected to Dim $objsys and to include all of the error checking code that would normally follow.

Quote:

Quote:

Not sure of M$ logic of not syncronizing these when a computer is part of a domain.




Yup, it's a puzzler.




Once you commit to using these fields I think you'll find the desire to keep them in concert. I'd rather not invoke the AD object (unless I had to do a .put_) as I imagine the workstation data should reflect the AD data which would be set by WriteValue on the client as you suggest above.

Granted, this is starting to smell like a UDF but the macro would make it easier to get at the data in all cases. Can someone comment on the local system and network overhead of a macro vs. CreateObject? (Assume 10,000 clients)

Regardless, it's still a hell of a lot easier to:
Code:
If @ADDesc AND @ADDesc<>@Desc 
WriteValue(...

_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#148460 - 2005-09-26 06:43 PM Re: New Macros - @Desc and @ADDesc
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
well. if ad stuff is pulled anyways, then I understand but otherwise all those who don't need ad related info in their script would be penalized.
that's no good either.
@desc I understand even though it indeed is easy to pull via registry read too.
_________________________
!

download KiXnet

Top
#148461 - 2005-09-26 06:49 PM Re: New Macros - @Desc and @ADDesc
jtokach Offline
Seasoned Scripter
*****

Registered: 2001-11-15
Posts: 513
Loc: PA, USA
Agreed. I'd hope that @Site isn't populated until it's requested.
_________________________
-Jim

...the sort of general malaise that only the genius possess and the insane lament.

Top
#148462 - 2005-09-26 10:38 PM Re: New Macros - @Desc and @ADDesc
NTDOC Administrator Offline
Administrator
*****

Registered: 2000-07-28
Posts: 11631
Loc: CA
Quote:

@ADDesc - Reads the Description field of the computer object in AD





Well this is not really specific to AD either. This is available with NT 4 Domain as well. Was probably added to AD as carry over.

Changing the comments field on a Windows 2000/XP computer.

Method 1. Right click on My Computer, Left click on Manage, Right click on
Computer Management (Local), Left click Properties, select the middle tab called
Network Identification.

Method 2. From a command prompt enter the following command
net config server /srvcomment:"Asset Tag - Lastname, Firstname (82xx-xxxx)"

Method 3. From Server Manager for Domains locate the machine and double-click on it.
You will be able to enter the Description in the appropriate field now.

Method 4. (Not recommended)
Using REGEDIT, or REGEDT32 alter the following key
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\lanmanserver\parameters\srvcomment
 

Top
Page 1 of 1 1


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

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

Generated in 0.028 seconds in which 0.011 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