Hinzufügen eines Rechteeintrags zu einer Zugriffsrechteliste
Autor: Dr. Holger Schwichtenberg
ACL schreiben: Lese- und Schreibrechte fuer einen Benutzer setzenEingabedaten$DIR = "g:\daten\kunden" $BENUTZER = "HS" Hole ACL$ACL = Get-Acl $DIR "ACL vorher:" $acl | format-list ACE definieren$Rights = [System.Security.AccessControl.FileSystemRights] "ReadData, ReadExtendedAttributes, ReadAttributes, ReadPermissions" $Access=[System.Security.AccessControl.AccessControlType]::Allow $Inherit=[System.Security.AccessControl.InheritanceFlags]::ContainerInherit ` -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit $Prop=[System.Security.AccessControl.PropagationFlags]::InheritOnly $AccessRule = new-object System.Security.AccessControl.FileSystemAccessRule ` ($BENUTZER,$Rights,$Inherit,$Prop,$Access) ACE an ACL anfügen$ACL.AddAccessRule($AccessRule) ACL speichernset-acl -AclObject $ACL -Path $DIR Kontrolle$ACL = Get-Acl $DIR "ACL nachher:" $acl | format-list
$DIR = "g:\daten\kunden" $BENUTZER = "HS"
$ACL = Get-Acl $DIR "ACL vorher:" $acl | format-list
$Rights = [System.Security.AccessControl.FileSystemRights] "ReadData, ReadExtendedAttributes, ReadAttributes, ReadPermissions" $Access=[System.Security.AccessControl.AccessControlType]::Allow $Inherit=[System.Security.AccessControl.InheritanceFlags]::ContainerInherit ` -bor [System.Security.AccessControl.InheritanceFlags]::ObjectInherit $Prop=[System.Security.AccessControl.PropagationFlags]::InheritOnly $AccessRule = new-object System.Security.AccessControl.FileSystemAccessRule ` ($BENUTZER,$Rights,$Inherit,$Prop,$Access)
$ACL.AddAccessRule($AccessRule)
set-acl -AclObject $ACL -Path $DIR
$ACL = Get-Acl $DIR "ACL nachher:" $acl | format-list
Liste aller Codebeispiele Definition '.NET Framework Class Library' PowerShell Community Portal