FileSystemRights の解釈で論理エラーが発生したため、他に何を入力しても常に読み取りアクセス許可が適用されていました。
ユーザー名のリストを提供し、ユーザーと同じ名前のフォルダーのアクセス許可を変更するための ps コマンドレットを作成しています。私のテストによると、このスクリプトは、許可または拒否エントリのユーザー用に新しい特別な acl エントリを作成しますが、エントリが既に存在する場合は変更しません。つまり、ユーザーが既に読み取りアクセス権を持っていて、書き込みアクセス権を付与しようとしても、エントリは変更されません。古いアクセス許可を完全に削除せずに、既存のアクセス許可を変更する方法がわかりません。
DirectoryInfo diDirInfo = new DirectoryInfo(FolderName);
DirectorySecurity dsDirSecurity = diDirInfo.GetAccessControl();
//These just interpet the objects for the rights and the allow/deny entries from the command line
FileSystemRights FSR = genFSR();
AccessControlType ACT = genAct();
dsDirSecurity.AddAccessRule(new FileSystemAccessRule(UserName, FSR, ACT));
diDirInfo.SetAccessControl(dsDirSecurity);
ModifyAccessRule を試してみましたが、同じ動作になりました。
FileSystemAccessRule fsaRule = new FileSystemAccessRule(UserName, FSR, ACT);
dsDirSecurity.ModifyAccessRule(AccessControlModification.Add, fsaRule, out modified);