User Tools

Site Tools


networking:windows:active_directory:folder_creation

This is an old revision of the document!


Standardized Active Directory User Folders

This is a batch file that quickly creates our standard set of folders for use with:

@echo off
rem WARNING! 
rem This script is intended to be used on a new (data) drive and manhandles permissions on the entire drive!
rem
set drive=E:
set domain=UI
net share Homes$ /d /y
net share Profiles$ /d /y
net share Redirected$ /d /y
takeown /F %drive% /R /D Y
rmdir /q /s %drive%\$RECYCLE.BIN
mkdir %drive%\Shares
mkdir %drive%\Homes
mkdir %drive%\Profiles
mkdir %drive%\Redirected
icacls %drive%\Shares /reset /T
icacls %drive%\Homes /reset /T
icacls %drive%\Profiles /reset /T
icacls %drive%\Redirected /reset /T
icacls %drive%\Shares /inheritance:r
icacls %drive%\Homes /inheritance:r
icacls %drive%\Profiles /inheritance:r
icacls %drive%\Redirected /inheritance:r

icacls %drive%\Homes /grant:r "ADMINISTRATORS":(OI)(CI)F /grant:r "SYSTEM":(OI)(CI)F /grant:r "CREATOR OWNER":(OI)(CI)(NP)(IO)F /grant:r "AUTHENTICATED USERS":(X,RD,RA,RC,REA)
net share Homes$=%drive%\Homes /grant:"ADMINISTRATORS",FULL /grant:"SYSTEM",FULL /grant:"Authenticated Users",FULL

icacls %drive%\Profiles /grant:r "ADMINISTRATORS":(OI)(CI)F /grant:r "SYSTEM":(OI)(CI)F /grant:r "CREATOR OWNER":(OI)(CI)(NP)(IO)F /grant:r "EVERYONE":F
net share Profiles$=%drive%\Profiles /GRANT:"EVERYONE",FULL

icacls %drive%\Redirected /grant:r "ADMINISTRATORS":(OI)(CI)F /grant:r "SYSTEM":(OI)(CI)F /grant:r "CREATOR OWNER":(OI)(CI)(NP)(IO)F /grant:r "EVERYONE":F
net share Redirected$=%drive%\Redirected /GRANT:"EVERYONE",FULL

dir %drive%
net share
icacls %drive%\*.*

set drive=
set domain=

echo "Folder structure has been created, permissions set and shares have been shared."

rem exit
networking/windows/active_directory/folder_creation.1504823747.txt.gz · Last modified: 2017/09/07 16:35 by gcooper