IPB

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Example VBScript for create an list of servers to import
zefrench
post Feb 9 2007, 04:48 PM
Post #1


Frequent user
**

Group: Members
Posts: 80
Joined: 27-November 06
Member No.: 557



This is a script I put together to go through active directory and create a text file of all the servers, ready to import.

I know this is not LUA, so please move this scirpt to the right forum if need be.

Martin

CODE
' This code makes a list of server to inport in intellipool
' ------ SCRIPT CONFIGURATION ------
strActiveDirectoryDomainDNSName = ""domain.com"
strObjectNamePrefix = "CUSTOMER-"
' ------ END CONFIGURATION ---------
strBase = "<LDAP://" & strActiveDirectoryDomainDNSName & ">;"
Set objFS = CreateObject ("Scripting.FileSystemObject")
Set objFileOut = objFS.OpenTextFile ("inm_listofservers.txt", 2, True)

strFilter = "(&(objectclass=computer)(objectcategory=computer)" & _
"(operatingSystem=*Server*));"
strAttrs = "cn;"
strScope = "subtree"
set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
Wscript.Echo strBase & strFilter & strAttrs & strScope
Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
objRS.MoveFirst
while Not objRS.EOF
Wscript.Echo objRS.Fields(0).Value
objFileOut.WriteLine( strObjectNamePrefix & lcase(objRS.Fields(0).Value) & ";" & lcase(objRS.Fields(0).Value) & "." & strActiveDirectoryDomainDNSName & ";" & "automatically imported")
objRS.MoveNext
wend

objFileOut.Close
Set objFileOut = Nothing
Set objFS = Nothing
Go to the top of the page
 
+Quote Post
RA
post Feb 9 2007, 06:44 PM
Post #2


INM wizard
**********

Group: Root Admin
Posts: 2,314
Joined: 24-August 04
From: Intellipool AB, Härnösand, Sweden
Member No.: 3



Nice work there, I should rename this forum "Scripts" instead !!


--------------------
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic

 



RSS Lo-Fi Version Time is now: 8th September 2010 - 07:13 AM