I am trying to copy the contents of certain folders to another folder using VBScript.
The goal is to enumerate a user's AD groups and then copy specific folder content based on those groups.
I have code, which is currently not working.
Dim Group,User,objFSO,objFolder,source,target,StrDomain
StrDomain = "domain.local"
FolderBase = "\\domain.local\netlogon\workgrps\icons"
Set net = CreateObject("wscript.network")
Struser = net.username
target = "\\fs1\users\"&net.username&"\Desktop\AppIcons\"
DispUserInWhichGroup()
Function DispUserInWhichGroup()
On Error Resume Next
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set User = GetObject("WinNT://" & strDomain & "/" & strUser & ",user")
For Each Group In User.Groups
source = FolderBase & Group.name
Set objFolder = GetFolder(source)
For Each file in objFolder.Files
objFSO.CopyFile source &"\"& file.name, target&"\"&file.name
Next
Next
End Function
This has been cobbled together from various sources, and I'm sure most of it is right, I just can't get it working completely.
Any assistance would be great.
Cheers.