amf2009 Posted April 14, 2009 Share 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. Link to comment Share on other sites More sharing options...
IcemanND Posted April 15, 2009 Share 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 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now