Continuing on from my previous post about setting permissions on all migrated users home directories here…
Re-permission each users subdirectory so only their user account has access (note that the homedir name and username must match),
for /f %%f IN (‘dir /ad /b E:\MigratedData\homedirs\’) DO cacls E:\MigratedData\homedirs\%%f /e /p %%f:F
It is also possible to share each migrated home directory (or any other set of subfolders) as its own hidden share, without the repetitious click, click,click of the share wizard and copious amounts of your time (that you’ll never get back). Let the command line take the strain! And the best bit? You don’t even need PowerShell to do it!
Create a hidden share for each users home directory (Note: home directory must have appropriate NTFS security in place)
for /f %%f IN (‘dir /ad /b E:\MigratedData\homedirs\’) DO net share %%f$=E:\MigratedData\homedirs\%%f /GRANT:Everyone,FULL
You could tighten up the share security only allowing the user themselves to have full control (in terms of share permissions – the underlying NTFS perms to that effect should already be in place), by changing /GRANT:Everyone,FULL to /GRANT:%%f,FULL
Note that double %% is necessary for using these commands in a batch file, If you want to run them straight on the command line, you’ll need to drop one of the % e.g. for /f %f IN…