在PowerShell中共享文件夹并设置权限 [英] Sharing a folder and setting permissions in PowerShell

查看:794
本文介绍了在PowerShell中共享文件夹并设置权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个在Vista Ultimate上运行的脚本来共享外部驱动器并将完全控制权分配给Everyone.我有一个批处理文件,可使用net share创建共享,但似乎没有更改权限的方法.我认为这在PowerShell中一定可行,但是我不知道从哪里开始.

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.

推荐答案

两个答案.

在PowerShell中,Get-ACL cmdlet将检索现有权限.然后,您可以使用.NET命令修改这些示例,然后运行Set-ACL将其应用回文件夹-这两个cmdlet的帮助包括示例,您可以从www.sapienpress.com下载"Windows PowerShell:TFM"的书籍示例. "=这本书还包含一些明确的例子.

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.

但是,这不值得您花费时间.实际上,文件ACL很难处理并且非常复杂.微软已经编写了一些可爱的工具来执行此操作,例如Cacls,而使用这些工具要容易得多.

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.

现在,所有这些都是FILE权限-您可能还会对更改SHARE本身的权限感兴趣.该工具是SUBINACL,您可以从Microsoft下载它.另请参见 http://cwashington.netreach.net/depo/view.asp?Index = 1127& ScriptType = vbscript .

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.

这篇关于在PowerShell中共享文件夹并设置权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆