-
Notifications
You must be signed in to change notification settings - Fork 1
/
import.ps1
39 lines (20 loc) · 1.07 KB
/
import.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
$InputBackupName = Read-Host -Prompt "Write the Name of the Backup"
$Backup = Import-CSV C:\Backup\+$InputBackupName
foreach ($acl in $Backup ) {
if( $acl.IdentityReference.StartsWith("CN=") -Or $acl.IdentityReference.StartsWith("OU=") -Or $acl.IdentityReference.StartsWith("DC=") ){
$InputDN = $acl.IdentityReference -replace '/',','
} else {
$path = "AD:\$InputDN"
$activedirectoryrights = $acl.ActiveDirectoryRights -replace ';',','
#Write-Host $activedirectoryrights
$array = $activedirectoryrights -split ", "
foreach($test in $array){
$ace = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $acl.IdentityReference, $test, $acl.AccessControlType
$aclToApply.AddAccessRule($ace)
}
#$ace = New-Object System.DirectoryServices.ActiveDirectoryAccessRule $acl.IdentityReference, $activedirectoryrights, $acl.AccessControlType
#s$aclToApply.AddAccessRule($ace)
Set-Acl -Path $path -AclObject $aclToApply
write-host "ACL Applied"
}
}