I have a domain called "OMNIA" on Server 2008 R2, in which the domain users are created by a script. The script creates a folder for that user and assigns them full access at both a folder and network level. However, whenever I log on as a created user and try to modify the contents of the folder, it throws up an Access Denied error message.
I have tried to grant the user full access and ownership of the folder through the Windows GUI, but I still get the same error. Does anyone have any idea why this is happening and if there is any way to fix it?
This is the contents of "addstaff.bat":
@echo off
rem %1 -> First Name
rem %2 -> Surname
set PASSWORD=DefaultPwd01
net user %2.%1 %PASSWORD% /add /profile:\\192.168.1.1\Profiles\Default /domain
net group "Staff" %2.%1 /add /domain
mkdir "E:\Profiles\%2.%1"
mkdir "E:\Profiles\%2.%1\My Documents"
mkdir "E:\Profiles\%2.%1\My Documents\My Music"
mkdir "E:\Profiles\%2.%1\My Documents\My Pictures"
mkdir "E:\Profiles\%2.%1\My Documents\My Video"
mkdir "E:\Profiles\%2.%1\My Documents\Downloads"
icacls \\192.168.1.1\Profiles\%2.%1 /grant:r OMNIA\%2.%1:(OI)(CI)(F) /T /C
icacls E:\Profiles\%2.%1 /grant:r OMNIA\%2.%1:(OI)(CI)(F) /T /C