$StartingPath = "C:\Users\administrador\Desktop\prueba"
$Right = "fullcontrol"
$Principal = "mio\c"
$Rule = New-Object System.Security.AccessControl.FileSystemAccessRule($Principal,
$Right,"ContainerInherit, ObjectInherit", "None","Allow")
foreach ($Folder in $(Get-ChildItem -Directory $StartingPath -Recurse)) {
$folderName = $Folder.fullname
$Acl=get-acl $folderName
$identidades = $Acl.access.identityreference
if($identidades -contains "MIO\c"){
if($Acl.removeAccessRule($Rule)){
write-host "Usuario $Principal borrado de la carpeta
$folderName"
}
Set-Acl $folderName $Acl
}
}