Sharing a folder and setting permissions in PowerShell

harriyott picture harriyott · Dec 30, 2008 · Viewed 52.4k times · Source

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.

Answer

Kenneth LeFebvre picture Kenneth LeFebvre · Oct 7, 2011

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.