If you need to revoke write permission from some shared folder after a certain time, you can easily do it by writing a PowerShell script and scheduling it. For the scheduling the task you need to use Windows Task Scheduler. So you can automatically revoke write permission from a shared folder. Here we will see how we achieve the same in Windows Server 2012 R2.
Let us say the folder is named as Estimates and it is located in the C: drive.
How to Automatically Revoke Write Permission from a Shared Folder in Windows Server 2012 R2
- Open notepad.
- Then copy the code below and paste it in the notepad.
$Acl = Get-Acl "C:\Estimates"
$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("yourdomain\authenticated users","Write","Deny")
Set-Acl "C:\Programming Fundamentals" $Acl
- Save it as
some_file_name.ps1, note the file extension.
Schedule the Script Using Windows Task Scheduler
- Click on Start.
- Search for Task Scheduler.
- Click on it.
- When the Task Scheduler opens, create a new folder.
- Name it as per your needs.
- Then create a task and schedule it at the time you wish to revoke the write permission from the shared folder.
- In the Actions tab, in the Program/script textbox, enter powershell.exe and in the Add arguments textbox, add location of the file (for instance,
- Click ok and that’s all you need to do.