Submitted By: Chris Harrod

Lists the current domain.

Visual Basic
Edit|Remove
' List Domain
' POC chris.harrod@gmail.com

On Error Resume Next



Set objNet = WScript.CreateObject( "WScript.Network" )

strFilename = "c:\scripts\list.txt"

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set objTextStream = objFSO.OpenTextFile(strFilename, 1)

Do Until objTextStream.AtEndOfStream

 	strComputer = objTextStream.ReadLine
 	
	Set wmi = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & _
     strComputer & "\root\cimv2")
  	wql = "select domain from Win32_ComputerSystem"
  	
  	Set results = wmi.execquery(wql)
  	
  	For Each obj In results
    		GetComputerDomain = obj.Domain
    		Wscript.echo strComputer & " is currently on Domain: " & GetComputerDomain
  	Next

Loop