Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 504
vishal goyal Avatar asked Jun 03 '14 11:06

vishal goyal


People also ask

How do I give permission to a folder for everyone?

Right-click the folder, and then click Properties. Click the Sharing tab, and then click Share to open the File Sharing dialog box. In the File Sharing dialog box, type Everyone in the box, and then click Add. By default, Read permissions are applied for the Everyone object.

How do I get permissions for sharing a folder in PowerShell?

To get the shared folder permissions using PowerShell, we can use the Get-SmbShare cmdlet.


1 Answers

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.

like image 134
Dane Boulton Avatar answered Oct 09 '22 17:10

Dane Boulton