Server-side

PS C:\> if ($PSVersionTable.PSVersion.Major -eq 2) { Add-Type -AssemblyName System.Core }
PS C:\> $pipe = New-Object System.IO.Pipes.NamedPipeServerStream("\\.\pipe\MyPipeName")
PS C:\> $pipe.WaitConnection()
PS C:\> $writer = New-Object System.IO.BinaryWriter($pipe)
PS C:\> [Byte[]]$data = 0x01, 0x02, 0x03, 0x04
PS C:\> $writer.Write($data)
PS C:\> $writer.Dispose()		# Disconnect pipe
PS C:\> 


Client-side

PS C:\> if ($PSVersionTable.PSVersion.Major -eq 2) { Add-Type -AssemblyName System.Core }
PS C:\> $pipe = New-Object System.IO.Pipes.NamedPipeClientStream("\\.\pipe\MyPipeName")
PS C:\> $pipe.Connect()
PS C:\> $reader = New-Object System.IO.BinaryReader($pipe)
PS C:\> $data = $reader.ReadBytes(4)
PS C:\> $data
1
2
3
4
PS C:\> $reader.Dispose()		# Disconnect pipe
PS C:\> 


Remark

.NET 3.5 이상 지원


References


신고

티스토리 툴바