Go Premium for a chance to win a PS4. Enter to Win


Powershell - create script for removing all ACLs and leaving only administrator and system

Posted on 2010-09-22
Medium Priority
Last Modified: 2012-08-13
Hello, I am thinking about script, which will get users from csv file, and remove them ACLs and leave only system, and administrator.

$DomainName = "xxx"
Import-CSV "C:\test.csv" | %{
  # Get the folder
  $Folder = Get-Item $_.ColumnA

$ACL = Get-ACL $Folder



Set-ACL $NewFullName -AclObject $ACL


Any ideas?

Mant BR
Question by:Radim88
  • 2
  • 2
LVL 42

Expert Comment

by:Meir Rivkin
ID: 33732687
the csv files contain list of folders (not users) from which you with to remove all ACL users except system and administrator, is that correct?

Author Comment

ID: 33732892
Yes the list of folders thats correct:


Author Comment

ID: 33732902
yes and I want to remove ACLs except of system and administrator for all folders listed in csv.


something like this.
LVL 42

Accepted Solution

Meir Rivkin earned 500 total points
ID: 33749348
follow chris-dent solution from this post:

to integrate it with reading folders from file, simply use the following:

foreach ($folder in Get-Content "c:\temp\folders.csv")

$ACL = Get-Acl -Path $folder


Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Suggested Courses

926 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question