Ich schreibe eine Funktion zum Gleichsetzen einer ACL von Pfad A zu Pfad B (Pfad A kann auch ein Server A und Pfad B auf Server B sein). Fast alles funktioniert wie erwartet, der Benutzer wird auf den Zielpfad deployed, aber die FileSystemRights werden nicht implementiert, obwohl ich "FullControl" in der Funktion fest codiert habe.FileSystemRights werden nicht bereitgestellt
Ich arbeitete nie mit ACLs in Powershell vor und von hier aus den meisten meinem Code kopiert: https://technet.microsoft.com/en-us/library/ff730951.aspx?f=255&MSPPError=-2147217396
Warum zum Einsatz zu tun bekommen meine FileSystemRights nicht?
Process {
# get ACL from source path
$gacl = get-acl $SourcePath | select -ExpandProperty Access | % {
$ErrorActionPreference = "SilentlyContinue"
[string]$user = ($_.IdentityReference).Value.split('\')[1]
[string]$AccessType = $_.AccessControlType
$FSRights = $_.FileSystemRights
if (!$user) { Write-Warning "User not found. Skipping ACL settings for this user. Username: $(($_.IdentityReference).Value)`n"}
else{
# Create ACL Object
$colRights = [System.Security.AccessControl.FileSystemRights]"FullControl"
$InheritanceFlag = [System.Security.AccessControl.InheritanceFlags]::None
$PropagationFlag = [System.Security.AccessControl.PropagationFlags]::None
$objType =[System.Security.AccessControl.AccessControlType]$AccessType
$objUser = New-Object System.Security.Principal.NTAccount($user)
$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType)
# Set the ACL
Write-Host "Setting ACL for User: $User on $DestinationPath" -ForegroundColor Green
$objACL = get-acl $DestinationPath
$ErrorActionPreference = "Stop"
Try {
$objACL.AddAccessRule($objACE)
$sacl = set-acl $DestinationPath $objACL
Write-Host "Success!`n" -ForegroundColor Green
} Catch {
Write-Host "Failed! ErrorMessage:" -ForegroundColor Red
$_.Exception.Message
}}
}}