Share all subfolders as individual hidden shares

Continuing on from my previous post about setting permissions on all migrated users home directories here…

Re-permissioning Users Home Directories

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…

 

 

Did you like this?
Tip cyberfella with Cryptocurrency

Donate Bitcoin to cyberfella

Scan to Donate Bitcoin to cyberfella
Scan the QR code or copy the address below into your wallet to send some bitcoin:

Donate Bitcoin Cash to cyberfella

Scan to Donate Bitcoin Cash to cyberfella
Scan the QR code or copy the address below into your wallet to send bitcoin:

Donate Ethereum to cyberfella

Scan to Donate Ethereum to cyberfella
Scan the QR code or copy the address below into your wallet to send some Ether:

Donate Litecoin to cyberfella

Scan to Donate Litecoin to cyberfella
Scan the QR code or copy the address below into your wallet to send some Litecoin:

Donate Monero to cyberfella

Scan to Donate Monero to cyberfella
Scan the QR code or copy the address below into your wallet to send some Monero:

Donate ZCash to cyberfella

Scan to Donate ZCash to cyberfella
Scan the QR code or copy the address below into your wallet to send some ZCash:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.