I dont speak VBscript, but i do speak perl.
read the contents from the text file into an refernce to a file object.
Then, based on the position in the array (multidimentional), feed that into
a " for each " loop that puts the values into the script. loop through until
there are no values in the array
wash, rinse, repeat.
In perl I would do (somthing like) this:
$args = $ARGV[0]; #takes the name of the file and gives it a reference
open(ARGS, "$args"); #opens a filehandle based on the ref
while(defined($line=<ARGS>)){
@array = $line;
$array[0] = strSubnetRDN;
$array[1] = strSiteObjectRDN;
$array[3] = strDescription
# use the data from the array ordinal reference above
Set objRootDSE = GetObject("LDAP://RootDSE")
strConfigurationNC = objRootDSE.Get
("configurationNamingContext")
strSiteObjectDN = strSiteObjectRDN & ",cn=Sites," &
strConfigurationNC
strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," &
strConfigurationNC
Set objSubnetsContainer = GetObject(strSubnetsContainer)
Set objSubnet = objSubnetsContainer.Create("subnet",
strSubnetRDN)
objSubnet.Put "siteObject", strSiteObjectDN
objSubnet.Put "description", strDescription
objSubnet.SetInfo
}
the "while" line will be executed as though it were reading one line at a
time from your data file, and when it reaches the end (thus not being
defined), it will stop.
other logic and steps could be added to print results of each add into a log
file to check for any problems. This should just give you an idea of how it
can be done with a loop.
NuTs
"Robin Briggs" <(E-Mail Removed)> wrote in message
news:420c01c3e43a$12150770$(E-Mail Removed)...
> I have found a useful code snipet on the MS web site to
> add subnets to AD Sites & Services. Works well for one
> subnet as you have to enter the subnet information into
> the script. I have to add 1,000+ subnets and would prefer
> to be able to specify an input file rather than having to
> cut/past or type this information for each subnet into
> the script, one at a time. I have a csv file that
> contains the subnet name, siteobject name and description
> which is all I want to enter for each subnet.
>
> The code I am using is as follows:
> strSubnetRDN = "cn=192.168.1.0/26"
> strSiteObjectRDN = "cn=USA-SITE1"
> strDescription = "Bldg. 1, Rochester, NY"
>
> Set objRootDSE = GetObject("LDAP://RootDSE")
> strConfigurationNC = objRootDSE.Get
> ("configurationNamingContext")
>
> strSiteObjectDN = strSiteObjectRDN & ",cn=Sites," &
> strConfigurationNC
>
> strSubnetsContainer = "LDAP://cn=Subnets,cn=Sites," &
> strConfigurationNC
>
> Set objSubnetsContainer = GetObject(strSubnetsContainer)
>
> Set objSubnet = objSubnetsContainer.Create("subnet",
> strSubnetRDN)
> objSubnet.Put "siteObject", strSiteObjectDN
> objSubnet.Put "description", strDescription
> objSubnet.SetInfo
>
> Any help anyone can offer is appreciated.
|