GPO scripts location

G

Guru Perplexe

Hello,
I want to write a script that connects a network drive to
a local server, depending on the site of the user.
So I write a GPO that launches the script, and I bind the
GPO with the correct site. OK.
The question is : where do I store this script ? A fixed
place is not a good idea, because it can be far away from
the user, on a slow WAN link. I wanted to store it in the
NETLOGON share of my AD domain controlers, but how can I
specify this in the GPO ? I tried "%logonserver%
\netlogon\script_name.bat", but it doesn't seem to work.

Thanks for your help ...
 
M

MS Newsgroups

If i understand you correctly, I believe you have 2 options.

Option 1

Create one script per site, create a group policy per site and apply your
script to that group policy. FRS will take care of the replication of your
script, and the script will run when a user logs on to the site.

Option 2

You can create 1 script, apply this script to the group policy you use for
your users and make your script aware on what site you are logging on to and
use conditionally mappings depending on what site you are logging on from.

Here is a sample for how to do this.

'**SCRIPT START
Dim AdsObj
Dim oWshNetwork

Set oWshNetwork=CreateObject("wscript.network")
Set AdsObj=CreateObject("adsysteminfo")

Select Case AdsObj.SiteName

Case "Site1"
oWshNetwork.MapNetworkDrive "F:","\\MyServer\Share1"
Case "Site2"
oWshNetwork.MapNetworkDrive "F:","\\MyServer\Share2"
End select

'**SCRIPT END

If you need anything clarified, please let me know

Niclas Lindblom
 
G

Guru Perplexe

Hello again,

Things are getting a little confusing for me ...

OK, I found I can store the logon script in the
sysvol\domain_name\policies\policy_ID\user\scripts, that
is : within the policy. I guess this is then the FRS which
manages the replication between controllers.
But I want this script to be common to several GPOs.
So where can I store the script ? I still think of the
netlogon share, but again, how do I say "Take the script
in the netlogon share of the domain controller that was
used at logon time" ?
The KB article 322241 says "type the path to the script or
click Browse to locate the script in the netlogon share of
the domain controller". Not any clearer for me.

Again, thanks for your help ...
 
G

Guru perplexe

Hello again,

Things are getting a little confusing for me ...

OK, I found I can store the logon script in the
sysvol\domain_name\policies\policy_ID\user\scripts, that
is : within the policy. I guess this is then the FRS which
manages the replication between controllers.
But I want this script to be common to several GPOs.
So where can I store the script ? I still think of the
netlogon share, but again, how do I say "Take the script
in the netlogon share of the domain controller that was
used at logon time" ?
The KB article 322241 says "type the path to the script or
click Browse to locate the script in the netlogon share of
the domain controller". Not any clearer for me.

Again, thanks for your help ...
 
M

MS Newsgroups

Jonathan,

How about this approach,

Create a group policy dedicated to your script. do all site awareness logic
in your script so that it becomes generic and will work correctly regardless
on what site a user logs on from. Then you apply this policy on a top level
OU where your user objects resides.

If this does not work, you have to provide us with some more information
about your directory design.

Good luck

Niclas LIndblom
 
G

Guru Perplexe

-----Original Message-----
Jonathan,

How about this approach,

Create a group policy dedicated to your script. do all site awareness logic
in your script so that it becomes generic and will work correctly regardless
on what site a user logs on from. Then you apply this policy on a top level
OU where your user objects resides.

If this does not work, you have to provide us with some more information
about your directory design.

Good luck

Niclas LIndblom

Hello,

Thanks for this solution. I guess it will work, and my
problem is solved. Still, my question remains : if I
wanted to have a script shared by several GPOs, where
should I store it, and how could I acess it ?

Thanks again ...
 
M

MS Newsgroups

Hi,

You can store your script anywhere within SYSVOL and thereby it will get
repliacted by FRS, then you simply have to browse to it when applying
scripts in a GPO.

hope this answers your question.

Regards

Niclas Lindblom
 
G

Guru Perplexe

-----Original Message-----
Hi,

You can store your script anywhere within SYSVOL and thereby it will get
repliacted by FRS, then you simply have to browse to it when applying
scripts in a GPO.

hope this answers your question.

Regards

Niclas Lindblom

Hello,

Well, no, this doesn't answer my question.
Let's say I want to launch the A script for each user in
an OU. OK, I can store it in the SYSVOL and pick it
graphically as I create the GPO.
But now, I want the A script to launch B script or C
script depending on some other info (site name, group
membership, ...). How can I write the command in the A
script for it to find the B and C scripts, which could be,
for instance, in the netlogon share of the domain
controller that was used to open the session ?
I hope I am clear enough ...

Thanks on more time !
 
S

Serge Gagnon

Hi Guru,

I have done a similar set-up here at the office.

All my users in a specific OU use the same login script. Within that script
i use a command line that will execute specific command depending on the
membership of the users.

Here's the command from the login script:

FOR /F "usebackq delims=\ tokens=2" %%z IN (`W:\TOOLS\whoami /GROUPS
/NOVERBOSE`) DO CMD /X /C W:\TOOLS\GROUPS1.BAT %%z

As you can see here, in W:\TOOLS i have the whoami tool and another batch
file called GROUPS1.bat which is passed the group name for arguments.

-- example of group1.bat --
if "%1" == "ACCOUNTING" @net use Y: \\SERVER\ACCOUNTING /PERSISTENT:YES >nul
2>&1
-- end of example --

There is a way to integrate all of this into one script but i didnt get to
it yet.

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top