I want to create a folder for each user if they do not already have one on a Windows file server when the user logs in each time.
So for example, I have user "jdoe", I would like to be able to create a share called "jdoe" automatically the first time this user logs in. And subsequently make this share available every time this user logs in after the share is created.
I have the policy working to the point where, if I manually create the share name for the user, the network drive gets mapped correctly. The last piece would be to create the share if it does not exist.
The policy setting looks like this:
Is there is a way to fully automate this process/policy or does this need to be done with a custom logon script or something?
Update 1:
These are what the folder permissions look like. Maybe this will help give you a better clue as to why the share isn't being created the first time the drive is mapped.
And here are the advanced options for Authenticated Users.
Update 2:
I have something working now at least, although I don't really think this is the best or cleanest way to do this. I have created two scripts, 1 for creating the share if it does not exist and the other to map the share.
I'm thinking that there has to be an easier, or at least less complicated, more obvious way to do this?
The problem at this point is likely the permissions on the folder \\server\share.
The user or the computer account (I don't remember which... been a while) needs to have the ability to create the new folder %username%. Check both the NTFS and share rights. From there it should occur on its own. At least it did when I still needed to set this up. :)
EDIT -
I think that this was user accounts, not computer. I tended to use 'Authorized Users' for this setting.
Also you should be able to grant the "Create Folder" right to the "Only This Folder" setting on the shared folder. That should be the minimum to do what you want.
EDIT - See the official documentation on the subject here. Specifically look at the "Folder Redirection permissions" section.
The Group Policy to map a drive only actually performs the mapping. It's not capable of creating the share automatically. You'll have to do this programatically, probably by way of a login script.
This link is to a GREAT blog post detailing how to create a PowerShell script that will check for the presence of a directory, and if it does not exist, it will create it (and I think the script goes so far as to share it).
If you couple pieces of the login script with your GPO, you'll have a solution that suits your needs.
I suspect that for this to work, you have to configure the 'root' folder (Users) in the manner used for Redirected profiles or Redirected folders.
In this example, the 'special' permissions for CREATOR OWNER & Authenticate Users are:
I had to use a combination of two different scripts for this to work. I first run a powershell script that checks to see if a directory exists and if it doesn't, creates it.
createshare.ps1
The next script just deletes the old share name and mounts the new share.
mapdrives.bat
I have a group policy set to run the powershell script and then run the bat file to map the drives at user logon.