amf2009 Posted April 14, 2009 Posted April 14, 2009 Hi guys,Does anyone know of a script that I can use to do the following?Enumerate an OU in AD for existing ComputernamesE.G.:SERVER1SERVER2SERVER3Then name computer in sysprep to highest number + 1Name Computer SERVER4Thnaks for your assistance.
IcemanND Posted April 15, 2009 Posted April 15, 2009 From microsoft scriptcenter should list all computer in an OU, modify line 3 for you OU and domainConst ADS_SCOPE_SUBTREE = 2'set ADLOOKUP value to your ORG and OUADLOOKUP = "Select Name, Location from 'LDAP://OU=AA, DC=COMPANY, DC=com' "Set objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"Set objCOmmand.ActiveConnection = objConnectionobjCommand.CommandText = _ ADLOOKUP _ & "Where objectClass='computer'"objCommand.Properties("Page Size") = 1000objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.ExecuteobjRecordSet.MoveFirstDo Until objRecordSet.EOF Wscript.Echo "Computer Name: " & objRecordSet.Fields("Name").Value Wscript.Echo "Location: " & objRecordSet.Fields("Location").Value objRecordSet.MoveNextLoop
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now