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