vishal goyal
vishal goyal

Reputation: 183

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

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?

Upvotes: 13

Views: 43469

Answers (1)

Dane Boulton
Dane Boulton

Reputation: 1325

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.

Upvotes: 37

Related Questions