Skip Ribbon Commands
Skip to main content

Ondrej Sevecek's English Pages


Engineering and troubleshooting by Directory Master!
MCM: Directory

Quick Launch

Ondrej Sevecek's English Pages > Posts > How to share a folder and set its share permissions from PowerShell
August 16
How to share a folder and set its share permissions from PowerShell

If you want to share a folder from PowerShell and also apply its share permissions in a single command, you can do it just this simple:

net share 'shareName=D:\shareRoot\folderName' '/Grant:Everyone,CHANGE' '/Grant:Administrators,FULL'

Note that I actually granted two user groups some different share permissions, you can just use the /Grant parameter any number of times you need to. Note also that the individual /Grant parameters must be enclosed in apostrophes, because they contain comma, which PowerShell would interpret as an array of strings instead of the single parameter value.

For example, the following is a more complex sample PowerShell script which automatically shares all subfolders within a common root folder:

$rootDir = 'G:\Repository'

dir $rootDir | select -expand name | % {

  net 'share' ('{0}={1}\{0}' -f $_, $rootDir) '/Grant:Everyone,CHANGE' '/Grant:Administrators,FULL'


What I like on PowerShell is its ability to combine its programmatic syntax, variables and other elements with normal command line executable programs such as the NET is an example of. Cheers!


Command Is not working

Using Powershell I am trying to share a folder to everyone
net share 'shareName=D:\shareRoot\folderName' '/Grant:Everyone,CHANGE' '/Grant:Administrators,FULL'

But it is not working
 on 03/06/2014 12:59

Add Comment

Sorry comments are disable due to the constant load of spam *

This simple antispam field seems to work well. Just put here the number.


You do not need to provide any value this column. It will automatically fill with the name of the article itself.

Author *

Body *