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.
views:
3377answers:
1Two answers.
In PowerShell, the Get-ACL cmdlet will retrieve the existing permissions. You then modify those using .NET commands, and run Set-ACL to apply it back to the folder - the help for these two cmdlets includes examples, and you can download the book examples from www.sapienpress.com for "Windows PowerShell: TFM" = the book also contains explicit examples.
However, it is not worth your time. Practically speaking, file ACLs are a royal pain to deal with an incredibly complicated. Microsoft has already written lovely tools to do this, like Cacls, and it's far easier just to use those.
Now that's all FILE permissions - you may also be interested in changing the permissions on the SHARE itself. The tool for that is SUBINACL, and you can download it from Microsoft. See also http://cwashington.netreach.net/depo/view.asp?Index=1127&ScriptType=vbscript.