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

x
?
Solved

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

Posted on 2010-09-22
4
Medium Priority
?
1,069 Views
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

xxxxxxx

$ACL.AddAccessRule($AccessRule)

Set-ACL $NewFullName -AclObject $ACL

}



Any ideas?

Mant BR
0
Comment
Question by:Radim88
  • 2
  • 2
4 Comments
 
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?
0
 

Author Comment

by:Radim88
ID: 33732892
Yes the list of folders thats correct:

ColumnA
folder1
folder2
folder3
0
 

Author Comment

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

ColumnA
\\xxx\folder1
\\xxx\folder2
\\xxx\folder3

something like this.
0
 
LVL 42

Accepted Solution

by:
Meir Rivkin earned 500 total points
ID: 33749348
follow chris-dent solution from this post:
http://www.experts-exchange.com/Programming/Languages/Scripting/Powershell/Q_25343265.html

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

}
0

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