Computer(s) that user can log on to the windows domain
#--------------------------------------
#Save the following as user_pc.vb
#--------------------------------------
'This script returns only a list of the computer objects
'found in the Servers OU. How do we know that it returns
'only computer objects? Note the Filter, which specifies
'just one item: Computer.
'Only work for win2k3 and XP because it use ADAM OU
'Set colItems = GetObject ("LDAP://ou=Servers, dc=fabrikam, dc=com")
'colItems.Filter = Array("Computer")
'For Each objItem in colItems
' Wscript.Echo objItem.CN
'Next
'-------------------------------------------------------
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\temp\computers.txt", ForAppending, True)
' This one work for win2k enumerate All the Objects in an Active Directory OU
Set colItems = GetObject _
("LDAP://OU=Developers,dc=artificial-life,dc=com")
For Each objItem in colItems
If objItem.class="user" And objItem.AccountDisabled = FALSE Then
Set objUser = GetObject("LDAP://cn=" & objItem.CN &",OU=Developers,dc=artificial-life,dc=com")
'Wscript.Echo objItem.CN
'Wscript.Echo "Log on computer(s): " & objUser.userWorkstations
objTextFile.WriteLine(objItem.CN & vbTab & objUser.userWorkstations)
End If
Next
沒有留言:
發佈留言