Submitted By: Lance Montana
Uses the Net View utility to return a list of domain computers.
Set objShell = CreateObject("WScript.Shell") Set objExec = objShell.Exec("cmd /c net view /Domain:fabrikam.com") Do While Not objExec.StdOut.AtEndOfStream strText = objExec.StdOut.ReadLine() If InStr(strText, "\") Then strText1 = Right(strText, Len(strText)-2) arrText = Split(strText1," ") strComputer = arrText(0) WScript.Echo strComputer End If Loop
Set objShell = CreateObject("WScript.Shell") Set objExec = objShell.Exec("cmd /c net view /Domain:fabrikam.com") Do While Not objExec.StdOut.AtEndOfStream strText = objExec.StdOut.ReadLine() If InStr(strText, "\") Then strText1 = Right(strText, Len(strText)-2) arrText = Split(strText1," ") strComputer = arrText(0) WScript.Echo strComputer End If Loop