我运行get-acl -path "D:\path\to\file" | fl get-acl -path "D:\path\to\file" | fl :
Path : Microsoft.PowerShell.Core\FileSystem::D:\path\to\file Owner : SERVER\user Group : G:S-1-5-21-467825353-2970891935-3496973838-513
我想修改Group值。
我能find很多关于修改所有者的文章,但不是那么多。
我不确定修改组的价值会做你认为会的。
在get-acl的输出中显示的组值指的是所有者的安全组(在您的情况下是Server \ user的安全组)。
另外,请记住,Get-ACL只会这样做 – 它会获取ACLlogging。 它不设置ACLlogging。
如果您尝试授予特定域安全组对文件或文件夹的访问权限,请使用以下命令:
$newacl = New-Object System.Security.AccessControl.FileSystemAccessRule ("domain\username","ACCESSLEVEL","ACTION") $object = Get-ACL "\\server\pathtofolder" $object.SetAccessRule($newacl) Set-ACL -Path "\\server\pathtofolder" -AclObject $newacl
如果您想将服务器A上的文件夹上的NTFS权限复制到服务器B上的文件夹,则应该按照您的要求进行操作。
$newacl = New-Object System.Security.AccessControl.FileSystemAccessRule ("domain\username","ACCESSLEVEL","ACTION") $server1object = Get-ACL "\\server1\pathtofolder" $server2object = $server1object $server2object.SetAccessRule($newacl) Set-ACL -Path "\\server2\pathtofolder" -AclObject $newacl
如果你更喜欢使用PowerShell脚本,你可以使用上面的代码来创build自己的脚本。
ACCESSLEVEL将被replace为适当的权限级别(例如FullControl或Read)。
行动将被replace为允许或拒绝。
现在,我已经回答了您的问题,但我意识到您可能更喜欢预先制作的PowerShell脚本。
还有预制的PowerShell脚本来pipe理NTFS权限。
你可以find一些在“嘿,脚本!博客”( https://blogs.technet.microsoft.com/heyscriptingguy/2014/11/22/weekend-scripter-use-powershell-to-get-add-and-remove -ntfs-permissions / )和CodePlex( https://ntfssecurity.codeplex.com/ )。