3

ローカル コンピューター上のすべてのユーザーが利用できるように、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 ) 
4

1 に答える 1

1

適切なコンストラクターを使用する必要があります。そのプロパティは後で設定できません。これはトリックを行います:

$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("p","In",100, "Byte", "Asynchronous", 32768, 32768, $PipeSecurity);
于 2013-10-25T01:07:31.973 に答える