[Webinar] Streamline your web hosting managementRegister Today

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

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

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