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

copy files based on AD group membership

Status
Not open for further replies.

Dani3l

Technical User
Dec 16, 2010
4
US
Hello,

I cannot seem to get the below section to work. I would like for the script to copy a file based on the users group membership within AD. Can someone please tell me where I am going wrong?

Thank you,
Daniel

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Script section below
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
Case "URLshortcut"
set objFSO = CreateObject("Scripting.FileSystemObject")
strSource = "\\testserv\UserSetup\XXXXXXXXX.url"
strDestination = "C:\Documents and settings\" & UserString & "\Desktop"
objFSO.CopyFile strSource, strDestination, true
 
Select Case [!]UCase[/!](GroupObj.Name)
Case "URLSHORTCUT"

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
in your script make sure you are not enumerating through the group membership using

For Each GroupObj In UserObj.Groups

more than once.
everytime you do this enumeration it costs lots of time (e.g. if you are doing it as a logonscript). you are better to do the enumeration 'For Each GroupObj In UserObj.Groups' and store the results in a hash/array and then for the rest of your script read the hash/array...you will find it much much quicker

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
Hey guys,

This is the other part of the login script. The upper section of the script came from what was posted by Mark D Mac. Something is not working as my file will not copy over. I do believe it's most likely from the "Set UserObj". I am very thankful for any feedback.
~~~~~~~~~~~~~~~~~~~~~~~~~~
Script
~~~~~~~~~~~~~~~~~~~~~~~~~~

ON ERROR RESUME NEXT
Dim WSHShell, WSHNetwork, objDomain, DomainString, UserString, UserObj, Path

Set WSHShell = CreateObject("WScript.Shell")
Set WSHNetwork = CreateObject("WScript.Network")
'domain name pull
DomainString = Wshnetwork.UserDomain
'username pull
UserString = WSHNetwork.UserName
Set UserObj = GetObject("WinNT://" & DomainString & "/" & UserString)
'disconnect network drives
'WSHNetwork.RemoveNetworkDrive "F:", True, True
'WSHNetwork.RemoveNetworkDrive "G:", True, True
'connect network drives
'WSHNetwork.MapNetworkDrive "F:", "\\testserv\Fdrive",True
'WSHNetwork.MapNetworkDrive "G:", "\\testserv\Gdrive",True

For Each GroupObj In UserObj.Groups
Select Case UCase(GroupObj.Name)
Case "URLSHORTCUT"
set objFSO = CreateObject("Scripting.FileSystemObject")
strSource = "\\testserv\UserSetup\Shortcuts\Shortcut.url"
strDestination = "C:\Documents and settings\" & UserString & "\Desktop"
objFSO.CopyFile strSource, strDestination, true
End Select
Next
'888888888
'Script Section Removed.
'8888888

'Begining of script that pulls username, domain name and checkes AD groups came from:
'Author: Mark D. MacLachlan
'URL:
wscript.quit
 
>strDestination = "C:\Documents and settings\" & UserString & "\Desktop"
[tt]strDestination = "C:\Documents and settings\" & UserString & "\Desktop[red]\[/red]"[/tt]

Also do you know what does it mean by "on error resume next"?
 
That should be a comment. It was something I did not completely remove. I will try adding the "\". However I kindly question if the section on pulling domain name/group memebership is even working.
 
It's Alive!

Thank you all for your input. I cannot believe my problem was that simple.

Thanks again guys!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top