Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete user profiles based on group memberships.

Status
Not open for further replies.

bmclean2

MIS
Jul 20, 2005
22
0
0
US
I have the need to delete user profiles off of 10+ terminal servers for members of a specific group. Does anybody know how to do this through scripting?

Specifics:
Approximately 70 members in the group
Profiles could exist on one or more of the 10 terminal servers

Would like to :
1. read the members of the specified group
2. check a server to see if profile exists
3. delete if profile exists
4. repeat on all servers

Thanks for your help.
 
Seems the easiest thing to do would be to dump the group membership to a text file. Then read that text file and delete the folders if they exist. Something like this:

Code:
On Error Resume Next

'open the file system object
Set oFSO = CreateObject("Scripting.FileSystemObject")
set WSHShell = wscript.createObject("wscript.shell")
'open the data file
Set oTextStream = oFSO.OpenTextFile("ulist.txt")
'make an array from the data file
UserArray = Split(oTextStream.ReadAll, vbNewLine)
'close the data file
oTextStream.Close
For Each strUser In UserArray
	If oFSO.FolderExists("C:\Documents and Settings\" & strUser) Then
		oFSO.DeleteFolder "C:\Documents and Settings\" & strUser
	End If
Next

I hope you find this post helpful.

Regards,

Mark
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top