How to set Write permission on a folder for Everyone Using Powershell

空扰寡人 提交于 2020-12-05 05:09:40

问题


I am trying to share a folder with everyone and using the below command but it is not working.

NET SHARE Movies=C:\foldername  "/GRANT:Everyone,FULL"

After runnign this command a message comes 'Movies Shared Successfully' but When i check folder permission it does not show the same.

Can anyone tell me the correct command?


回答1:


your net share works just fine. To set the folder permissions you need to set the ACL permissions:

$sharepath = "C:\foldername"
$Acl = Get-ACL $SharePath
$AccessRule= New-Object System.Security.AccessControl.FileSystemAccessRule("everyone","FullControl","ContainerInherit,Objectinherit","none","Allow")
$Acl.AddAccessRule($AccessRule)
Set-Acl $SharePath $Acl

You will notice that "Everyone" will show up with full access permissions on the security tab of the folder.



来源:https://stackoverflow.com/questions/24013990/how-to-set-write-permission-on-a-folder-for-everyone-using-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!