Automated Folder/share/permissions script
-
Monday, February 11, 2013 10:40 PM
Hey Team
Don’t have much of an idea of how to script so putting the question to your all.
We have a VB script that creates an AD user and sets up that pointer for the home drive (+ adds the user to groups etc), this has been untouched for some time and now needs a makeover.
What I want to do is limit the manual work people have to do, currently they create the folder using the username, then they add modify rights to this folder for that user and then share it as hidden share.
What I would like to achieve is either a script that pulls the username and created the folder, assigns the permissions and then shares it.
EG
User is Bob, it creates the new folder \\Server\Home\Bob then adds the NTFS permissions for Bob to Modify then shares the folder as Bob$ so that I can access it via the address \\server\Bob$ (which is what the pointer is set to in AD for the Home drive)
If I can’t add this to the existing VB script then a separate script would be fine.
Thank you in advance
GRCrowe
All Replies
-
Monday, February 11, 2013 10:45 PMModerator
Hi,
Unfortunately this isn't a scripts-on-demand forum.
However, I can suggest that there are numerous products available that provide for automatic provisioning of user shares and permissions. I would suggest looking into that as you would then be using a supported product and not have to worry about scripting. One product that I have used in the past is Hyena.
Bill
-
Sunday, February 24, 2013 10:22 AMModerator
The first question would be - where do you get the name bob from? A CSV, from the Console, From a text file??
Assuming it's a csv then you want to do some thing like this:
$users = import-csv c:\foo\users.csv
Foreach($user in $user) {
New-ADUser $user # there's a whole lot more than this you'd need to add but this is the basics
mkdir c:\users\$user
net share "$user"+'$"=c:\users\$user /grant:$user,full}As noted, you need to add a few more parameters (password, etc) to the new-aduser.
Alo, I strongly reccomend you do NOT use the approach to shares you are asking for. If you have large numbers of users, then you end up with large numbers of hidden shares, which will slow down start-up of you r file server and will dramatically slow down browsing of the machine.So
So this is a partial answer. using PowerShell - feel free to try it out, and come back and ask more specific questions.
Thomas Lee <DoctorDNS@Gmail.Com>
- Proposed As Answer by Thomas LeeMVP, Moderator Sunday, February 24, 2013 10:22 AM
- Marked As Answer by IamMredMicrosoft Employee, Owner Tuesday, March 05, 2013 3:50 AM

