WMI scripting template that runs the script against all the computers found in the Finance OU in the domain fabrikam.com.

Visual Basic
Edit|Remove
On Error Resume Next

Set objOU = GetObject("LDAP://OU=Finance,dc=fabrikam,dc=com"
objOU.Filter = Array("Computer")

For Each objComputer in objOU
    strComputer = objComputer.CN

    ' =====================================================================
    ' Insert your code here
    ' =====================================================================

    Set objWMIService = GetObject _
        ("winmgmts:\\" & strComputer & "\root\cimv2")
    Set colItems = objWMIService.ExecQuery _
        ("Select * From Win32_OperatingSystem")
    For Each objItem in ColItems
        Wscript.Echo strComputer & ": " & objItem.Caption
    Next

    ' =====================================================================
    ' End
    ' =====================================================================

Next