Forum Discussion
craigbowens
Feb 17, 2022Copper Contributor
Script to change permissions on multiple folders
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 ...
- 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" }
Feb 12, 2023
I 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
--karthik
Feb 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.