Forum Discussion
Script to change permissions on multiple folders
- Feb 18, 2022
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" }
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, 2023I guess, but could you explain what the folder structure is? Perhaps using the NTFS module is easier? https://www.powershellgallery.com/packages/NTFSSecurity/4.2.4
- --karthikFeb 14, 2023Copper Contributor
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.