We will be deploying "dynamic" classrooms using SCCM, and thus will also need to create OU's and matching users and homedirs on the fly. I am currently trying to figure out how to edit the security rights for these homedirs via a script. I've had limited success using google, because a lot looks outdated, so I wanted to see what ServerFault thinks is the best way.
What I need to do: - Create the folder (not quite the problem) - Share it and set permissions to Full Control for Everyone - change NTFS settings to "Change" or "Modify" for a single user, recursively
The other parts of the script are currently done in vbscript, but I can obviously call a different script from within this one if need be. PowerShell could be an option (if it's possible to begin with) but I'm eager to hear other options as well!
Thanks
Here is a PowerShell script that does what you wish.
I cribbed it and patched it together from a couple of other sites, 1 and 2. It works on my Windows 7 machine. For more information on the filesystemaccessrule object, look here.
I love CMD.EXE... (not really):
That makes the directory, adds "DOMAIN\user" with "Change" permissions to the directory (which will inherit to subfolders and files) and shares the directory. The first two commands can be run against UNC paths if you want but the
net share
must be executed on the server where the shared directory resides. (There was an oldrmtshare.exe
tool in one of the Windows NT Resource Kit distributions that had roughly the same syntax asnet share
but could create shares on remote computers.)Should be able to use the command
calcs
.