Browse Tag

Windows Server

Set Folders as Read Only using Powershell

Awhile back, I had to create a script that set permissions on a folder to Read Only on a Windows Server. Trying this as a batch file was more difficult than with Powershell.

The script will read a CSV file, which will contain the username and folder that you want to set as read only. The child folders will inherit the Read Only permission from the folder it sets as Read Only for that user.

This will run in a loop and output information in a text file as a log. Pretty handy to see if it set it correctly or not. I do notice one issue which is that if you have a ton of files in the directory, it will log that in the log file. In the future, I might create separate log files per user folder to lessen the amount of data in the one log file.

This script has been tested on Server 2008/R2 and Server 2012/R2. Make sure the execution policy for Powershell is set as Unrestricted while running this script and then turning it back on to Restricted.

Keep Reading