WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

ADSI
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

AD MachineRole Property


Question:

I need to extract the value of the AD machineRole property an AD object. This is an "enumeration" type value and will tell is computer is DC, Standalone Server, Member Server, Workstation, etc. I still examples of using WMI to gather this type of information, but I do not want to run script on each computer, I just want to query AD. Can this be done and if so, can you provide example. Thanks

Answer:

You wil need to adjust this to your network topology and AD configuration.Also needs error handling.
AddExtender("wwads34i.dll")

; Assumes computers are in this container.
sComputers = "LDAP://shamrock/CN=Computers,DC=jclass,DC=org"
lComputers = dsGetChldPath(sComputers, "computer")

; Iterate through computer list.
nCount = ItemCount(lComputers, @TAB)
For x=1 To nCount

   ; Get the role.
   sCompPath = ItemExtract(x, lComputers, @TAB )
   sRole = dsGetProperty(sCompPath, "machineRole")

   ;  Display the result.
   Message(sCompPath, sRole)
Next

Article ID:   W16789
File Created: 2007:07:03:14:26:16
Last Updated: 2007:07:03:14:26:16