12

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?

vishal goyal
  • 173
  • 1
  • 4
  • 15
  • 2
    If *it is not working*, then *what exactly* happens? No share is created at all, wrong permissions are being set, an error message is being risen, something else? – vonPryz Jun 03 '14 at 12:13
  • 3
    As written, this has nothing to do with PowerShell or even programming. It would be better on Server Fault. – alroc Jun 03 '14 at 13:30
  • vonPryz, After execution of the command in powershell, messgae comes "Movies shared Successfully" but when i check to the folder it does not show the permission for everyone. Arloc, I have tried this command with Command prompt the below command cacls C:\FolderName /t /e /g Everyone:f and it runs successfully. But i want to share the folder with Powershell Command – vishal goyal Jun 05 '14 at 04:22

1 Answers1

36

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.

Dusty Vargas
  • 863
  • 6
  • 17
Dane Boulton
  • 1,305
  • 1
  • 11
  • 15