Merging WMI and ADSI

Now that you know that both the ADSI script and the WMI script work as advertised, merging the two scripts is a rather easy task. By merging them, you will connect to Active Directory, perform a query of all computers in the workstation OU, take the returned data into a recordset, iterate through the recordset, and enable DHCP on each workstation in the recordset until you reach the end of the file. Along the way, echo out the results of the DHCP operation. The new script is called AdOuWmiDHCP.vbs.

You need to assign a computer name to the variable Target. You do this inside the While Not...Wend loop by using Target = oRecordSet.Fields("name"), because as you walk through the recordset, Target is the name you want to get back. ...

Get Microsoft® Windows® Scripting Self-Paced Learning Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.