Sharing a folder and setting permissions in PowerShell

前端 未结 4 1936
刺人心
刺人心 2021-02-12 22:31

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,

4条回答
  •  眼角桃花
    2021-02-12 23:04

    Two 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 and 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.

提交回复
热议问题