Member_2_5956489
asked on
Adding NTFS Permissions for files that a different user has ownership of
I'm looking for a script that will add user NTFS permissions whenever a different user has ownership of files located in a specific directory.
For example:
For each file in directory J:\folder that user "Domain\UserName" is the owner of, add user "Domain\NewUser" with read/write permission.
I'm not sure how much it matters, but the server is 2003 R2.
For example:
For each file in directory J:\folder that user "Domain\UserName" is the owner of, add user "Domain\NewUser" with read/write permission.
I'm not sure how much it matters, but the server is 2003 R2.
ASKER
Hi Akalyan911,
I'm only looking to have the permissions changes on a specific folder on a specific share.
Does Group Policy restrict itself to a specific folder of a specific share?
I'm only looking to have the permissions changes on a specific folder on a specific share.
Does Group Policy restrict itself to a specific folder of a specific share?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi NewVillageIT
Thanks for the batch file. It works! The only caveat, is the batch needs to be run in the directory were I want the files to be changed are located. This is because the icacls command is only being passed the file name and not the full path.
When running from the correct directory; it works great!
Many Thanks!
Thanks for the batch file. It works! The only caveat, is the batch needs to be run in the directory were I want the files to be changed are located. This is because the icacls command is only being passed the file name and not the full path.
When running from the correct directory; it works great!
Many Thanks!
ASKER
Thanks for the quick response!
You're welcome. Glad to help.
Re: the "...only being passed the file name and not the full path", try change the DoIt section like:
Re: the "...only being passed the file name and not the full path", try change the DoIt section like:
:DoIt
echo.
set owner=%1
set fn=%2
set ffn=%~f2
if %fn%=="" goto :eof
echo owner=%owner%
echo fn=%fn%
if /i %owner%=="%GrantChk%" (
ECHO icacls "%ffn%" /grant %GrantTo%:^(R,W^)
)
goto :eof
create the group policy for particular OU.. New Group Policy --> Under User configuration --> Drive Mapping --> \\Server Name\Sharedrive\Label As\
It will allow whomever is logged in having read & right permissions.. for that particular user..