如何设置一个Powershell命名管道供本地计算机上的所有用户使用?Powershell命名管道安全?
我正在编写一个小的PowerShell脚本,我需要能够让本地计算机上的任何用户能够写入将由该脚本使用的命名管道。
我可以得到管道设置了以下内容:
$pipe=new-object System.IO.Pipes.NamedPipeServerStream("\\.\pipe\mypipe")
$pipe.WaitForConnection()
$sr = new-object System.IO.StreamReader($pipe)
while (($cmd= $sr.ReadLine()) -ne 'exit')
....
我不知道如何与这个使用System.IO.Pipes.PipeSecurity结合。
编辑:我使用PS v2,如果它很重要。
EDIT2:
我做的越来越创建了一个名为管道安全定义了一些进展。仍然不确定如何绑定它。
$PipeSecurity = new-object System.IO.Pipes.PipeSecurity
$AccessRule = New-Object System.IO.Pipes.PipeAccessRule("Users", "FullControl", "Allow")
$PipeSecurity.AddAccessRule($AccessRule)
$pipe=new-object System.IO.Pipes.NamedPipeServerStream("\\.\pipe\mypipe");
$pipe.SetAccessControl($PipeSecurity)
我认为你只需要在'new-object'中使用接受PipeSecurity对象的重载。请参阅[这是我的老问题](http://stackoverflow.com/questions/3478166/named-pipe-server-throws-unauthorizedaccessexception-when-creating-a-seccond-ins)问在C#中的类似问题,你可能会把它翻译成PS。 –