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 Andrzejek on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy files to dir

Status
Not open for further replies.

terry712

Technical User
Oct 1, 2002
2,175
GB
sorry afraid i'm crap at programming - so struggling to google for the bist i need - it should be fairly simple

basically want to export the users of an AD group so just to a txt or csv.

then basically for each user of this group create a sub directory and copy some files to it

i would traditionally use a batch file but not really bother of the mechanism - any help appreciated
 
something like this

Code:
'create file system object
set objFSO = CreateObject("System.FileSystemObject")

'Get DNS Domain
set objLDAP = GetObject("LDAP://RootDSE")
strDomain = objLDAP.Get("DefaultNamingContext")

'Get Groups
set objGroups = GetObject("GC://cn=Users," & strDomain)

'Iterate groups
for each objGroup in objGroups
   if (objGroup.Name = "MyGroup") then
      strGroupFolder = "C:\Groups\" & objGroup.Name & "\"
      set objFile = objFSO.OpenTextFile(strGroupFolder & "user.txt", 2, true, 0)
      for each objUser in objGroup.Members
         strUserFolder = strGroupFolder & "\" & objUser.Name & "\"
         objFile.WriteLine objUser.Name
         objFSO.CreateFolder strUserFolder
         objFSO.CopyFile "C:\File1.ext", strUserFolder
         objFSO.CopyFile "C:\File2.ext", strUserFolder
      next
      objFile.Close
   end if
next

-Geates

"I hope I can feel and see the change - stop the bleed inside a feel again. Cut the chain of lies you've been feeding my veins; I've got nothing to say to you!"
-Infected Mushroom

"I do not offer answers, only considerations."
- Geates's Disclaimer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top