Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1071
  • Last Modified:

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

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
Radim88
Asked:
Radim88
  • 2
  • 2
1 Solution
 
Meir RivkinFull stack Software EngineerCommented:
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
 
Radim88Author Commented:
Yes the list of folders thats correct:

ColumnA
folder1
folder2
folder3
0
 
Radim88Author Commented:
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
 
Meir RivkinFull stack Software EngineerCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now