命名管道如何工作
服务器负责设置命名管道,然后等待一个或多个客户端连接。然后,服务器和客户端将命名管道视为一个文件,使用 CreateFile、ReadFile 和 Write 文件通过管道进行通信。完成后,它们都可以像标准文件一样关闭管道。

利用powershell创建命名管道
try {
$pipeName = "bad_pipe"
$pipe = New-Object system.IO.Pipes.NamedPipeServerStream($pipeName)
Write-Host "Listening on \\.\pipe\$pipeName"
$pipe.WaitForConnection();
$sr = new-object System.IO.StreamReader($pipe);
$msg= $sr.ReadLine()
Write-Host "I received a message: ", $msg
}
catch {
Write-Host "Pipe Creation Failed..."
$_
return 0
}
