Sharing a folder and setting permissions in PowerShell

前端 未结 4 1920
刺人心
刺人心 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:14

    The Carbon PowerShell module has two functions that will do this for you: Install-SmbShare and Grant-Permission. I would download it and give it a try.

    Install-SmbShare -Name MyShare -Path X:\ -FullAccess 'Everybody' `
                     -Description 'My super-awesome file share!' 
    Grant-Permission -Identity Everyone -Permission FullControl -Path X:\
    

    Disclaimer: I am the author and creator of Carbon. I recommend using this module because there are a lot of caveats and potholes to look out for when installing shares and granting permissions. These two function take care of that for you.

提交回复
热议问题