Feb 17 2022 11:55 AM
I am involved in a project to migrate users H: drive data to OneDrive. After we migrate their data to OneDrive, we want to change their H: drive folder and files to read-only. I have found a cacls command to change the permissions (CACLS K:\foldername /T /E /C /P username:R) but I need to do this for specific user's H: drives. o I need the script to read from a txt file to perform the cacls command on each of the folders in the txt file. Is there a smart person out there that can help?
Feb 18 2022 01:39 AM
Solution@craigbowens You could try something like using c:\temp\users.txt as input with a username per line. Not tested this, but I think it should work...
foreach ($user in get-content c:\temp\users.txt) {
cacls.exe "k:\$($user)" /T /E /C /P "$($user):R"
}
Feb 22 2022 05:59 AM
Yes! Thank you very much!
Feb 22 2022 06:11 AM
Feb 11 2023 06:29 PM
Hello - Thanks for that script as I was looking for the same. It worked. Can we have the same with icacls instead of cacls?
Can you also add a script that can give modify access only to one particular subfolder pls? subfolder name is the same for all users.
Feb 12 2023 10:53 AM
Feb 14 2023 03:52 PM
Hi Thank You for your answer.
There will be one folder for each user (with their own names as folder name) under one main directory. They will have their own personal files in their folders. All such user folders will have their own content plus one folder with common name and this is created by IT for some application access.
I hope the below example explains it.
ex:
p:\username1\operations
p:\username1\schedules
p:\username1\commonfoldername
p:\username2\AccountsPayable
p:\username2\AccountsReceivable
p:\username2\commonfoldername
I can try NTFS security but I am not a great scripter and I am going to take time to figure it out.
Immediate help from an expert will be great. So, please.
Feb 18 2022 01:39 AM
Solution@craigbowens You could try something like using c:\temp\users.txt as input with a username per line. Not tested this, but I think it should work...
foreach ($user in get-content c:\temp\users.txt) {
cacls.exe "k:\$($user)" /T /E /C /P "$($user):R"
}