Solved

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

Posted on 2010-09-22
4
1,059 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
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:
sedgwick earned 125 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. 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

Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…
This tutorial will walk an individual through the steps necessary to install and configure the Windows Server Backup Utility. Directly connect an external storage device such as a USB drive, or CD\DVD burner: If the device is a USB drive, ensure i…
The viewer will learn how to dynamically set the form action using jQuery.

631 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