pmcguire
asked on
Active Directory Script Get User's Home folder and Terminal Services Profile
I am needing a script to gather all users in an OU and list their Home folder and their Terminal Services Profile in a text file. With this information i need delete the home folder and Profile from the servers. Also i need their email address so i can delete them for our external spam/Virus scanning provider. All users in the OU will be deleted after this information is collected
You can use the csvde command line tool to do this. Something like this should work.
CSVDE -d "OU=Users,DC=domain,dc=com" -r objectCategory=person -l "cn, profilePath, homeDirectory, mail"-f users.csv
ASKER
Forgive me for being dumb. Both of these sound like they will work but i don't know how to implement them. The first on i copied to notepad and modified for my domain and saved it as a vbs file. Ran it and i get nothing. The second copied it to notepad and saved as a bat file. Still nothing. I am running from a workstation. Should i be on a domain controller?
You need to adjust mine, so it has the correct OU information, then run it on the domain controller.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Has this solution worked for you?
ASKER
The last bit of code read the ou i wanted but only wrote the summary to the text file.
02/05/2008
Total Records found:64
What needs to change to get it to list the info for each user in the OU?
02/05/2008
Total Records found:64
What needs to change to get it to list the info for each user in the OU?
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\OUUserlist.txt", 8, True)
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name,homedirectory,ProfilePath FROM 'LDAP://OU=PENDING DELETION,DC=ftsad,DC=com' WHERE objectCategory='user'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
ObjTextfile.WriteLine(Date)
Objtextfile.WriteBlankLines(2)
Do Until objRecordSet.EOF
ObjTextFile.writeline objRecordSet.Fields("Name").Value & vbTab & objRecordSet.Fields("homedirectory").Value & vbTab & objRecordSet.Fields("TerminalServicesProfilePath").Value
objRecordSet.MoveNext
Loop
Objtextfile.WriteBlankLines(2)
ObjTextfile.WriteLine("Total Records found:" & objRecordset.RecordCount)
Objtextfile.WriteBlankLines(2)
ObjTextFile.close
ASKER
I could not get the terminal services profile path to work. everything else works when you take the terminal services profile out. Thanks for your help.
Open in new window