Mapping drives through GPO

Captain Pooka

Daemon Poster
Messages
1,108
I'm running server 2003, so as you can imagine mapping drives is sort of a pain (so.. it just hasn't been done in the past). I need it done now.

Code:
On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
Set objNetwork = CreateObject("Wscript.Network")

strUserPath = "LDAP://" & objSysInfo.UserName
Set objUser = GetObject(strUserPath)

For Each strGroup in objUser.MemberOf
    strGroupPath = "LDAP://" & strGroup
    Set objGroup = GetObject(strGroupPath)
    strGroupName = objGroup.CN

    Select Case strGroupName
        Case "Pre-KTeachers_Grp"
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"
        
        Case "KinderTeachers_Grp" 
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

        Case "FirstGradeTeachers_Grp"
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

        Case "SecondGradeTeachers_Grp"
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

	Case "ThirdGradeTeachers_Grp"
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

	Case "FourthGradeTeachers_Grp"
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

	Case "FifthGradeTeachers_Grp"
            objNetwork.MapNetworkDrive "T:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

	Case "Administration"
            objNetwork.MapNetworkDrive "S:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

	Case "Quincytestgrp"
            objNetwork.MapNetworkDrive "S:", "\\server\share"
	    objNetwork.MapNetworkDrive "M:", "\\server\share"

    End Select
Next

I started work here last year and the technology portion was in a big mess. I'm still in the process of cleaning up this school district. This VBS was in place, but it never worked. I edited it and customized it, it still doesn't work. Any ideas?

Thanks!
 
This is how it was setup at my school when I got here (also 2003 - welcome to the world of education where we are supposed to prepare the students for the technology they will see in college and the real world but can't afford to upgrade our software to do that).

if InGroup ("Group1")
Use P: "\\server\share1"
Use I: "\\server\share2"
Else
use I: "\\server\share1"
use P: "\\server\share2"
endif

We have this in the netlogon folder on our DC and we have a login.bat file that we set to run on each user in AD and all that .bat file does is call up login.txt which is where this is, along with some other stuff.

Not real sure if it will help or if there is something else that runs as well to make sure it all works....
 
Last edited:
I don't know if that's the part that's wrong with mine. I guess I could have a bunch of "If" and "End If"s , but I would rather use Case and list the group.

I'll work on if and end if and see what happens.

Someone else have a suggestion? :)

Thanks for the reply!
 
Do you have windows 7 clients?
if you do I'd suggest drive mapping via the use of GPO rather than vbscript.
(much easier to manage)


in other news, there is absolutely nothing wrong with your script.

I've just tested it and it works absolutely fine.
if there is nothing wrong programatically with your script, then there must be something wrong with what you're selecting.

I'd suggest that you throw an echo statement here:

strGroupName = objGroup.CN

wscript.echo strGroupName

Select Case strGroupName
Case "Pre-KTeachers_Grp"


to help you debug.

also bear in mind that the groups are case sensitive, I've also had some troubles getting the case statement to work with group names with spaces in them.
 
I guess there's something wrong with my GPOs then. This is really bothering me. No one can install anything without typing in admin name/PW. No where in my GPO is this a condition. Also, in my GPO it states NOT to automatically update computers. Well they're all automatically updating anyway. Some even say "Rebooting in 10 minutes to apply updates" and does not give them the option to postpone. It's really making me mad...

Code:
Computer Configuration>Administrative Templates>Windows Components>Windows Update> 

Allow Automatic Updates immediate installation Disabled 
Automatic Updates detection frequency Disabled 
Configure Automatic Updates Disabled 
Enable recommended updates via Automatic Updates Disabled 
Enabling Windows Update Power Management to automatically wake up the system to install scheduled updates Enabled 
No auto-restart with logged on users for scheduled automatic updates installations Enabled 
Re-prompt for restart with scheduled installations Enabled
The plan was to push updates manually all at once. I haven't gotten that far though. There's so much I need to do here ><

Back to the GPO problem:

I would love to manage mapped drives through GPO rather than VBScript, however my coordinator refuses to upgrade our parent DC to the 2008 schema, so we're stuck in 2003. I don't want to use those W7 utilities as I already have this script written up.

I have this script in user configuration>Windows Settings>Scripts>Logon
I have NO idea why it's not taking effect. Even with a gpupdate /force... nothing. I would hate to hire someone out to figure out why my GPs arn't working like they're supposed to :(

Thanks for your help
 
One thing you can do is go to the top of your AD tree and turn off inheritance. I was having issues with something...can't remember what now...and it was coming from Group Policy, so I just went to the top level and turned off inheritance. Then from the 2nd level I created my own GP and it solved my issues. A bit of a work-around and it will probably screw up the next guy after you...but that's their problem, right...LOL
 
You know, it's actually working great for my test OU and my test account now. I found that I didn't have the VBS placed in an accessible UNC to everyone ;) But... now it is and only my test account works.

Actually I lied. I don't really know what's going on. I have a laptop next to me that I'm testing on.
The test account works on the laptop AND my computer.
My account also works on the laptop, however it does not work on my main computer.
The teacher account I'm using to test doesn't work on the laptop or my computer.

:confused:

---------- Post added at 07:57 AM ---------- Previous post was at 07:53 AM ----------

I also tried making a GPO that JUST had the VBS in it. That's also not working. I can see that both policies are active on the account by doing a gpresult.
 
Last edited:
Alright... So my account is working on the laptop, but not my computer.
The teacher account isn't working on either.

I tried simply running the VBS (Don't know why I didn't do that earlier) and here's what I came up with.

When running the VBS, my account maps the drives on my computer. So... for some reason this GPO isn't taking effect on my account.

When running the VBS, my teacher account does not map the drives. I can't see why for the life of me. All the information in my VBS is correct.

When I add my account and my teacher account to the test OU, still doesn't work. However, when I add my teacher account to my testgroup (last group on my VBS) the teacher account then works. So something has to be wrong with the group... but when comparing the two groups there is nothing different. I'm going to recreate the group.

Recreating the group didn't work. Now I see another thing to pile on.
Running the VBS does not work when she's simply in the Fourth grade group. So I added her to the test group, She worked! However, she added the drives from BOTH groups. So... it's like the VBS is working for fourth group, but ONLY when she's in the test group. I'm at a loss.

Recreating the group did not work. However, again, when added to my test group it added the mapped drives from both groups.

It's like a clogged drain. And when you add the users to the test group (IE add draino) it lets everything through at once.
 
Last edited:
Do all the groups have security rights and access to the shares on the server that you are trying to map to?
 
I am curious what is going on with your GPO's. You should run an RSOP test against a user and DCdiag to see if you are having any bigger issues that need to get resolved.
 
Back
Top Bottom