Avatar of juslearning
juslearning asked on

Writing a batch file

To all the scripting guru's out there (admittedly I am not one)... I know enough about active directory to know that it is possible (preferred) to have drive mapping done by security permissions, but alas, I missed that class of scripting 101. What I would like is to have a script that has an array of possible drives to be mapped but will only map the drives if the appropriate NTFS permissions are met, any assistance to this end would be very well appreciated.
This can be accomplished using either Visual Basic, a Batch file, or Powershell whatever the preferred method I would like it to be scalable and easy so changes can be made on the fly with even the least savvy IT person able to edit it, thanks.
Working in a Windows environment with Win 7 and a mix of Server 2003 and 2008 R2, this would be a logon script an added bonus would be to have the same script be able to assign printer based on group security permissions too...
IT AdministrationVisual Basic ClassicPowershellVB ScriptWindows Batch

Avatar of undefined
Last Comment

8/22/2022 - Mon

It isn't actually scripting really, and it easier to do through AD- IMHO.

is a decent one on this.  My only comment is to make your names of the security groups or your GPO reflect the drive letters (if it matters) or more descriptive as possible.    They kind of gloss over this, so in AD, you would have already made a security group that allows access to the drive.  I also remove the default authenticated users from the second window and add my security group in AD.  I tend to use the same one if possible, so the drive only shows up if they also have rights to do something in it.

If you leave it as authenticated user, then everyone will get the drive, but when they double click it will say access denied.

When you want a particular person to have a drive, you will then jsut add them in AD to the security group you had the GPO apply to, then have them log out and back in...

Part of the issue is I do not want to handle it using GPOs as not all folks following me in the job will be savvy with AD and GPOs also I am low in the totem pole regarding domain level rights. So keeping it local with regards to a logon script so that anyone with local domain admin rights can edit, makes life easier and less to explain, you know what I mean?

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Steve Knight

I have an example login script here too in VBScript of mine which shows results in a status window using IE etc.


For anything new I would be using Group Policy preferences too, otherwise a group policy based login script allocated to relevant containers, though I understand that some people do prefer to point specific user login scripts using their user property instead / aswell.

Whichever way you end up doing it you aren't going to get the drives mapped based on the NTFS permissions, aside from anything else you could have NTFS permissions allowing / denying access for a user at  x:\somedir but they have access to a specific file in that dir or a level durther down.

Share permissions you could read I suppose but the most logical is to use groups, either:

Group "Map drive X to server1-share1" - check for this in login script
Group "Some users in this group" - put users in this group, and put group in "Map x drive ...." etc. or check if the user is in "some users in this group" and map the drive.

Other more logical ways of course is to use DFS, the user has one or more drives mapped to \\domain.local\dfs-share  and then under that you create links to the actual shares they need.

Waffled on a lot more than intended to there but you get the idea, ask questions if needed.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck

I will test these out first thing when I return to work, thanks so far for all the input...