在PowerShell中共享文件夹并设置权限

编程入门 行业动态 更新时间:2024-10-23 22:27:23
本文介绍了在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下载"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 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下载它.另请参见 cwashingtonreach/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 cwashingtonreach/depo/view.asp?Index=1127&ScriptType=vbscript.

更多推荐

在PowerShell中共享文件夹并设置权限

本文发布于:2023-11-12 11:51:11,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581428.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:共享文件夹   权限   PowerShell

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!