Solved

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

Posted on 2010-09-22
4
1,054 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

A brief introduction to what I consider to be the best editor for PowerShell.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 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