How to change permissions on an existing folder share from the command line without having to delete the share and recreate it

command-line-interfacenetwork-sharewindows-server-2008

I used the following to create a folder share called "Running Virtual Machines" on a Hyper V R2 server:

net share "Running Virtual Machines"="C:\Hyper V\Running Virtual Machines"

Now I need to change the permissions on the share to allow users to access the share but using the following gives me the error "You used an option with an invalid value":

net share "Running Virtual Machines" /GRANT:domain/username,FULL

I have also tried:

net share "Running Virtual Machines"="C:\Hyper V\Running Virtual Machines" /GRANT:domain\username,FULL

This gives me the message "The name has already been shared."

How do I change permissions on an existing folder share from the command line without having to delete the share and recreate it?

Best Answer

You can do this with the PowerShell cmdlets Grant-SmbShareAccess and Revoke-SmbShareAccess

There are some examples in this TechNet blog post: http://blogs.technet.com/b/omers/archive/2013/09/14/assigning-file-share-permissions-using-power-shell.aspx