How can I set up a Powershell named pipe to be available to all users on the local computer?
I'm writing a small Powershell script and I need to be able to have any user on the local computer be able to write to a named pipe that will be consumed by this script.
I can get the pipe set up with the following:
$pipe=new-object System.IO.Pipes.NamedPipeServerStream("\\.\pipe\mypipe")
$pipe.WaitForConnection()
$sr = new-object System.IO.StreamReader($pipe)
while (($cmd= $sr.ReadLine()) -ne 'exit')
....
I'm not sure how to use the System.IO.Pipes.PipeSecurity in conjunction with this.
EDIT: I'm using PS v2 if it matters.
EDIT2:
I've made some progress in getting a named pipe security definition created. Still not sure how to bind it.
$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 )