Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sharing a folder and setting permissions in PowerShell

I need a script to run on Vista Ultimate to share an external drive and assign full control to Everyone. I've got a batch file to create the share using net share, but there doesn't seem to be a way to change the permissions. I reckon this must be possible in PowerShell, but I have no idea where to start.

like image 348
harriyott Avatar asked Dec 30 '08 10:12

harriyott


2 Answers

As of WMF 4:

New-SmbShare –Name ShareName –Path C:\LocalFolder –FullAccess Username

http://technet.microsoft.com/en-us/library/jj635722.aspx

like image 52
xcud Avatar answered Oct 07 '22 20:10

xcud


In case you're searching for an answer to this question, but you're running Windows 7 (instead of Vista), as I was, you might be interested to know that permissions can be set in the NET SHARE command, now, directly.

For instance,

NET SHARE Movies=M:\Movies /GRANT:Everyone`,READ

will create a share and give Everyone read-only permissions to it.

Instead of READ, you can use CHANGE or FULL as well.

like image 38
Kenneth LeFebvre Avatar answered Oct 07 '22 20:10

Kenneth LeFebvre