Why does Set-Acl on the drive root try to set ownership of the “object”?

后端 未结 5 1917
一向
一向 2020-12-07 22:45

I would like to change the ACL of the C: drive. What im trying to do is remove the permission that a user can create a folder directly on the drive. I tested th

5条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-07 23:31

    I found the answer. Microsoft says

    Unfortunately Get-Acl is missing some features. It always reads the full security descriptor even if you just want to modify the DACL. That’s why Set-ACL also wants to write the owner even if you have not changed it. Using the GetAccessControl method allows you to specify what part of the security descriptor you want to read.

    Replace the Get-Acl call with

    $acl = (Get-Item $path).GetAccessControl('Access')
    

提交回复
热议问题