Benutzer-Werkzeuge

Webseiten-Werkzeuge


powershell:ownerrechte
no way to compare when less than two revisions

Unterschiede

Hier werden die Unterschiede zwischen zwei Versionen angezeigt.


powershell:ownerrechte [2017/04/26 16:00] (aktuell) – angelegt ronny
Zeile 1: Zeile 1:
 +====== Nur Fileowner berechtigen ======
 +
 +<code Powershell>
 +function Remove-ACLEntries
 +{
 +    [CmdletBinding()]
 +    param(
 +        [string]$File
 +    )
 +    $authusers = ((New-Object System.Security.Principal.SecurityIdentifier 'S-1-5-11').Translate([System.Security.Principal.NTAccount])).Value
 +    $acl = Get-Acl $File
 +    $acl.SetAccessRuleProtection($True, $False)
 +    $owner = $acl.owner;
 +    For($i=$acl.Access.Count - 1; $i -gt 0; $i--)
 +    {
 +        $rule = $acl.Access[$i]
 +        if ($rule.IdentityReference -ne $owner -or $rule.IdentityReference -eq $authusers) 
 +        {
 +            $acl.RemoveAccessRule($rule)
 +        }
 +    }
 +    Set-ACL -Path $file -AclObject $acl | Out-Null
 +}
 +</code>
 +
 +{{tag>[Powershell ACL ACE Owner entfernen]}}
  
powershell/ownerrechte.txt · Zuletzt geändert: 2017/04/26 16:00 von ronny

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki