'General AD query 'Author Felipe Ferreira 'DatE: 13/09/2007 'Version: 1.0 'edit line 32, OU etc.. 'edit line 42, AD parameter you need, look in ADSIedit for it.... 'input file should be users.txt with all UPN Dim iFSO : Set iFSO = CreateObject("Scripting.FilesyStemObject") Dim oFSO : Set oFSO = CreateObject("Scripting.FilesyStemObject") DIM USERNAME, strAnswer,inputfile,outputfile Dim strScriptPath, strScriptFile strScriptFile = WScript.ScriptFullname strScriptPath = Left(strScriptFile, Len(strScriptFile) - Len(WScript.Scriptname)) 'used to define the path from where the script file is located outputfile = strScriptPath & "usersBASIC.txt" inputfile = strScriptPath & "users.txt" Set ofile = oFSo.OpenTextFile(Outputfile,8, TRUE) Set ifile = iFSO.OpenTextFile(inputfile) Do until ifile.AtEndOfLine on error resume next Set WshNetwork = WScript.CreateObject("WScript.Network") UserName = ifile.ReadLine Set con = CreateObject("ADODB.Connection") con.Provider = "ADsDSOObject" con.open Set command = CreateObject("ADODB.Command") Set command.ActiveConnection = con command.CommandText = "SELECT * FROM 'LDAP://DOMAIN.com.local/OU=MYOU,DC=com,DC=local' WHERE userPrincipalName = '" & UserName & "'" command.Properties("searchscope") = 2 Set rs = command.Execute if rs.EOF then WScript.Echo "Account: '" & UserName & "' Not found in OU." end if Set UserObject = GetObject((rs("ADsPath"))) strAnswer = UserObject.SunriseProfile wscript.echo UserName & " is: " & strAnswer loop ofile.close wscript.echo "Done" wscript.quit